-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQ29.ts
25 lines (24 loc) · 1.07 KB
/
Q29.ts
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
// 29. 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!
const favoriteFruits: string[] = ["Banana","Mango","Cherry"];
if (favoriteFruits.includes("Banana")) {
console.log("You really like Bananas!")
}
if (favoriteFruits.includes("Mango")) {
console.log("You really like Mango!")
}
if (favoriteFruits.includes("Kivi")) {
console.log("You really like Kivi!")
} else{
console.log("Kivi is not in your favorite fruits list.");
}
if (favoriteFruits.includes("Cherry")) {
console.log("You really like Cherry!")
}
if (favoriteFruits.includes("Grapes")) {
console.log("You really like Grapes!")
} else{
console.log("Grapes are not in your favorite fruits list.");
}