-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq28.ts
27 lines (21 loc) · 1.03 KB
/
q28.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
26
// 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!
let favorite_fruits: string[] = ['blueberries', 'salmonberries', 'peaches']
for(var i=0; i<favorite_fruits.length; i++){
if( favorite_fruits[i] === 'bananas'){
console.log("You really like bananas!");
}
if (favorite_fruits[i] === 'apple'){
console.log("You really like apples!");
}
if (favorite_fruits[i] === 'apple'){
console.log("You really like blueberries!");
}
if( favorite_fruits[i] === 'kiwis'){
console.log("You really like kiwis!");
}
if (favorite_fruits[i] === 'peaches'){
console.log("You really like peaches!");
}
}