Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Finding the Average Price of Items | Section
JavaScript Essentials for Beginners - 1768407374405

bookChallenge: Finding the Average Price of Items

Oppgave

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).

Løsning

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 74
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

close

bookChallenge: Finding the Average Price of Items

Sveip for å vise menyen

Oppgave

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).

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 74
single

single

some-alt