Challenge: Counting Elements
Task
Swipe to start coding
You are given an array called fruitBasket that contains several fruit names.
Your tasks:
- Create a variable named
numberOfFruitsand assign it the length of thefruitBasketarray. - Use an
if...elsestatement to generate a message: - If there are 3 or fewer fruits, return:
"We have a small fruit basket with [number] fruits!" - If there are more than 3 fruits, return:
"We have a big fruit basket with [number] fruits!" - Use the
numberOfFruitsvariable inside the message. - Do NOT hardcode the number.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 5. ChapterΒ 9
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 1.35
Challenge: Counting Elements
Swipe to show menu
Task
Swipe to start coding
You are given an array called fruitBasket that contains several fruit names.
Your tasks:
- Create a variable named
numberOfFruitsand assign it the length of thefruitBasketarray. - Use an
if...elsestatement to generate a message: - If there are 3 or fewer fruits, return:
"We have a small fruit basket with [number] fruits!" - If there are more than 3 fruits, return:
"We have a big fruit basket with [number] fruits!" - Use the
numberOfFruitsvariable inside the message. - Do NOT hardcode the number.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 5. ChapterΒ 9
single