Challenge: Counting Elements
Task
Swipe to start coding
You are given an array called fruitBasket that contains several fruit names.
- Create a variable named
numberOfFruitsand assign it the length of thefruitBasketarray. - Use an
if...elsestatement to:- Print
"We have a small fruit basket with [number] fruits!"if there are 3 or fewer fruits. - Print
"We have a big fruit basket with [number] fruits!"if there are more than 3 fruits.
- Print
- Make sure you use the
numberOfFruitsvariable in your console messages. Do not hardcode any numbers.
Solution
Everything was clear?
Thanks for your feedback!
Section 1. Chapter 64
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 1.33
Challenge: Counting Elements
Swipe to show menu
Task
Swipe to start coding
You are given an array called fruitBasket that contains several fruit names.
- Create a variable named
numberOfFruitsand assign it the length of thefruitBasketarray. - Use an
if...elsestatement to:- Print
"We have a small fruit basket with [number] fruits!"if there are 3 or fewer fruits. - Print
"We have a big fruit basket with [number] fruits!"if there are more than 3 fruits.
- Print
- Make sure you use the
numberOfFruitsvariable in your console messages. Do not hardcode any numbers.
Solution
Everything was clear?
Thanks for your feedback!
Section 1. Chapter 64
single