-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq29.js
More file actions
24 lines (24 loc) · 1.12 KB
/
q29.js
File metadata and controls
24 lines (24 loc) · 1.12 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
// Favorite Fruit: Make a array of your favorite fruits, and then write a series of independent if statements that check for certain fruits in your array.
// • Make a array of your three favorite fruits and call it favorite_fruits.
// • Write five if statements. Each should check whether a certain kind of fruit is in your array. If the fruit is in your array, the if block should print a statement, such as You really like bananas!
var favorite_fruits = ['banana', 'mango', 'strawberry'];
if (favorite_fruits.includes('banana')) {
console.log("You really like bananas!");
}
if (favorite_fruits.includes('mango')) {
console.log("You really like mangoes!");
}
if (favorite_fruits.includes('strawberry')) {
console.log("You really like strawberries!");
}
if (favorite_fruits.includes('orange')) {
console.log("You really like oranges!");
}
if (favorite_fruits.includes('apple')) {
console.log("You really like apples! ");
}
favorite_fruits.forEach(function (favorite_fruit) {
if (favorite_fruits.includes(favorite_fruit)) {
console.log("You really like " + favorite_fruit);
}
});