-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2-bush-berries.js
More file actions
45 lines (33 loc) · 1.2 KB
/
2-bush-berries.js
File metadata and controls
45 lines (33 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
The space travellers have safely landed and are foraging for food in the natural wildlife.
There are bushes with many different colour berries.
The pink berries are the ONLY safe ones to eat.
If any other berries are present, it's best not to eat from the bush at all!
Create a function which checks if the bush has ALL PINK berries and is safe for the astronauts to eat from the bush.
Use the tests to confirm which message to return
*/
function bushChecker() {
}
/* ======= TESTS - DO NOT MODIFY ===== */
let bushBerryColours1 = ["pink", "pink", "pink", "neon", "pink", "transparent"]
let bushBerryColours2 = ["pink", "pink", "pink", "pink"]
const util = require('util');
function test(test_name, actual, expected) {
let status;
if (actual === expected) {
status = "PASSED";
} else {
status = `FAILED: expected: ${util.inspect(expected)} but your function returned: ${util.inspect(actual)}`;
}
console.log(`${test_name}: ${status}`);
}
test(
"bushChecker funtion works - case 1",
bushChecker(bushBerryColours1),
"Toxic! Leave bush alone!"
);
test(
"bushChecker funtion works - case 1",
bushChecker(bushBerryColours2),
"Bush is safe to eat from"
);