Section 1. Chapter 72
single
Challenge: 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
totalPriceand set it to0. - Use a
forloop to iterate through all elements of thepricesarray. - Add each price to
totalPrice. - After the loop completes, calculate the average price.
- Return the average value.
Solution
Everything was clear?
Thanks for your feedback!
Section 1. Chapter 72
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat