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

Ask AI

expand
ChatGPT

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

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
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt