Seksjon 1. Kapittel 38
single
Challenge: for Loop
Sveip for å vise menyen
Oppgave
Sveip for å begynne å kode
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.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 38
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