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

Swipe to show menu

book
Challenge: Calculating the Speed of a Car

Task

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.

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Β 4. ChapterΒ 3

Ask AI

expand
ChatGPT

Ask anything or try one of the suggested questions to begin our chat

book
Challenge: Calculating the Speed of a Car

Task

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.

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Β 4. ChapterΒ 3
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt