Challenge: for Loop
Tehtävä
Swipe to start coding
Imagine you are buying several items in a shop. Each item costs the same amount, and you want to calculate the total cost of all items.
- Initialize
totalCostto0. - The loop should start with
i = 0and run whilei < quantity. - Add
itemPricetototalCostinside the loop. - Return
totalCostat the end of the method.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 4. Luku 3
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Mahtavaa!
Completion arvosana parantunut arvoon 1.25
Challenge: for Loop
Pyyhkäise näyttääksesi valikon
Tehtävä
Swipe to start coding
Imagine you are buying several items in a shop. Each item costs the same amount, and you want to calculate the total cost of all items.
- Initialize
totalCostto0. - The loop should start with
i = 0and run whilei < quantity. - Add
itemPricetototalCostinside the loop. - Return
totalCostat the end of the method.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 4. Luku 3
single