Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Counting Elements | Exploring Arrays
Introduction to JavaScript

Swipe to show menu

book
Challenge: Counting Elements

Task

Swipe to start coding

  • Initialize numberOfFruits with the length of the fruitBasket array.
  • If numberOfFruits has 3 or fewer fruits, print: "We have a small fruit basket with [number] fruits!", where [number] should be the number of fruits.
  • If numberOfFruits has more than 3 fruits, print: "We have a big fruit basket with [number] fruits!".

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 9
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

Awesome!

Completion rate improved to 1.33

book
Challenge: Counting Elements

Task

Swipe to start coding

  • Initialize numberOfFruits with the length of the fruitBasket array.
  • If numberOfFruits has 3 or fewer fruits, print: "We have a small fruit basket with [number] fruits!", where [number] should be the number of fruits.
  • If numberOfFruits has more than 3 fruits, print: "We have a big fruit basket with [number] fruits!".

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

close

Awesome!

Completion rate improved to 1.33

Swipe to show menu

some-alt