Skip to content
This repository was archived by the owner on Oct 26, 2020. It is now read-only.

Js/ week3/ali haider #97

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
2-bush-berries mandatory exercise completed
  • Loading branch information
AliHaider-1 committed Jul 19, 2020
commit 861f5880b67c7c4211f46488e45242a6acaacff3
2 changes: 1 addition & 1 deletion week-3/2-mandatory/1-oxygen-levels.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Write a function that finds the first safe oxygen level in the array - Oxygen be
*/

function safeLevels(arr) {
var safeLevel = arr.find(function (value,index){
var safeLevel = arr.find(function (value){
if( parseFloat(value) > 19.5 && parseFloat(value) < 23.5){
return true;
}
Expand Down
20 changes: 18 additions & 2 deletions week-3/2-mandatory/2-bush-berries.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,26 @@
Use the tests to confirm which message to return
*/

function bushChecker() {

function colorCheck(color){
if (color ==="pink"){
return true;
}
}

function bushChecker(arr) {
let safeBerries = arr.every(colorCheck);
if (safeBerries === true){
return "Bush is safe to eat from";
}
else {
return "Toxic! Leave bush alone!";
}
}





/* ======= TESTS - DO NOT MODIFY ===== */

let bushBerryColours1 = ["pink", "pink", "pink", "neon", "pink", "transparent"]
Expand Down