Challenge: Counting Elements
Oppgave
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.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 64
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Fantastisk!
Completion rate forbedret til 1.33
Challenge: Counting Elements
Sveip for å vise menyen
Oppgave
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.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 64
single