SectionΒ 1. ChapterΒ 62
single
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Β 1. ChapterΒ 62
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat