Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Counting Elements | Section
JavaScript Essentials for Beginners - 1768407374405

bookChallenge: Counting Elements

Oppgave

Swipe to start coding

You are given an array called fruitBasket that contains several fruit names.

  1. Create a variable named numberOfFruits and assign it the length of the fruitBasket array.
  2. Use an if...else statement 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.
  3. Make sure you use the numberOfFruits variable in your console messages. Do not hardcode any numbers.

Løsning

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 64
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

close

bookChallenge: Counting Elements

Sveip for å vise menyen

Oppgave

Swipe to start coding

You are given an array called fruitBasket that contains several fruit names.

  1. Create a variable named numberOfFruits and assign it the length of the fruitBasket array.
  2. Use an if...else statement 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.
  3. Make sure you use the numberOfFruits variable in your console messages. Do not hardcode any numbers.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 64
single

single

some-alt