Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Calculating the Speed of a Car | Mastering Functions
Introduction to JavaScript

Sveip for å vise menyen

book
Challenge: Calculating the Speed of a Car

Oppgave

Swipe to start coding

If we have the amount of distance (distance) a car has traveled, and the time it took to to cover that distance (timeTaken), we can calculate the average speed that car had throughout the journey, using the formula:

python

Note

The distance is in meters, and the time is in seconds.

The given code uses the two variables, distance and timeTaken to calculate and show the speed of a car.

  • Define a function called calcSpeed.
  • Put the given code inside the calcSpeed function.
  • Execute the calcSpeed function twice.

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 4. Kapittel 3

Spør AI

expand
ChatGPT

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

book
Challenge: Calculating the Speed of a Car

Oppgave

Swipe to start coding

If we have the amount of distance (distance) a car has traveled, and the time it took to to cover that distance (timeTaken), we can calculate the average speed that car had throughout the journey, using the formula:

python

Note

The distance is in meters, and the time is in seconds.

The given code uses the two variables, distance and timeTaken to calculate and show the speed of a car.

  • Define a function called calcSpeed.
  • Put the given code inside the calcSpeed function.
  • Execute the calcSpeed function twice.

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 4. Kapittel 3
Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Vi beklager at noe gikk galt. Hva skjedde?
some-alt