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

Pyyhkäise näyttääksesi valikon

book
Challenge: Finding the Average Price of Items

Tehtävä

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

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 6. Luku 8
Pahoittelemme, että jotain meni pieleen. Mitä tapahtui?

Kysy tekoälyä

expand
ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

book
Challenge: Finding the Average Price of Items

Tehtävä

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

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 6. Luku 8
Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Pahoittelemme, että jotain meni pieleen. Mitä tapahtui?
some-alt