Challenge: Finding the Average Price of Items
Task
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
totalPrice
and set it to0
. - Use a
for
loop to loop through all the elements ofprices
and add their values tototalPrice
. - After the loop completes, output the
totalPrice
divided by the number of items (length ofprices
array).
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 6. ChapterΒ 8
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 1.33
Challenge: Finding the Average Price of Items
Swipe to show menu
Task
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
totalPrice
and set it to0
. - Use a
for
loop to loop through all the elements ofprices
and add their values tototalPrice
. - After the loop completes, output the
totalPrice
divided by the number of items (length ofprices
array).
Solution
Everything was clear?
Thanks for your feedback!
Awesome!
Completion rate improved to 1.33SectionΒ 6. ChapterΒ 8
single