Challenge: Finding the Average Price of Items
Uppgift
Swipe to start coding
You're working at a local electronics store. Your manager has asked you to calculate the average price of all the items in stock. Instead of doing the math manually, you decide to write a JavaScript program to get the job done quickly!
- Create a variable
totalPriceand set it to0. - Use a
forloop to loop through all the elements ofpricesand add their values tototalPrice. - After the loop completes, output the
totalPricedivided by the number of items (length ofpricesarray).
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 1. Kapitel 74
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.33
Challenge: Finding the Average Price of Items
Svep för att visa menyn
Uppgift
Swipe to start coding
You're working at a local electronics store. Your manager has asked you to calculate the average price of all the items in stock. Instead of doing the math manually, you decide to write a JavaScript program to get the job done quickly!
- Create a variable
totalPriceand set it to0. - Use a
forloop to loop through all the elements ofpricesand add their values tototalPrice. - After the loop completes, output the
totalPricedivided by the number of items (length ofpricesarray).
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 1. Kapitel 74
single