Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Finding the Average Price of Items | Discovering Loops
Introduction to JavaScript

Swipe to show menu

book
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 to 0.
  • Use a for loop to loop through all the elements of prices and add their values to totalPrice.
  • After the loop completes, output the totalPrice divided by the number of items (length of prices array).

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 6. ChapterΒ 8
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

Awesome!

Completion rate improved to 1.33

book
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 to 0.
  • Use a for loop to loop through all the elements of prices and add their values to totalPrice.
  • After the loop completes, output the totalPrice divided by the number of items (length of prices array).

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

close

Awesome!

Completion rate improved to 1.33

Swipe to show menu

some-alt