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

bookChallenge: Finding the Average Price of Items

Task

Swipe to start coding

You are working at a local electronics store. Your manager has asked you to calculate the average price of all items in stock.

Your tasks:

  • Create a variable totalPrice and set it to 0.
  • Use a for loop to iterate through all elements of the prices array.
  • Add each price to totalPrice.
  • After the loop completes, calculate the average price.
  • Return the average value.

Solution

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

bookChallenge: Finding the Average Price of Items

Swipe to show menu

Task

Swipe to start coding

You are working at a local electronics store. Your manager has asked you to calculate the average price of all items in stock.

Your tasks:

  • Create a variable totalPrice and set it to 0.
  • Use a for loop to iterate through all elements of the prices array.
  • Add each price to totalPrice.
  • After the loop completes, calculate the average price.
  • Return the average value.

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

some-alt