Challenge: for Loop
Uppgift
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.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 4. Kapitel 3
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Fantastiskt!
Completion betyg förbättrat till 1.25
Challenge: for Loop
Svep för att visa menyn
Uppgift
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.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 4. Kapitel 3
single