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
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Introduction to JavaScript

bookChallenge: Calculating the Speed of a Car

Task

Swipe to start coding

If we know the distance a car has traveled and the time it took to cover that distance, we can calculate its average speed using the formula:

Speed = Distance / Time Taken

The distance is measured in meters and the time in seconds.
Use the following values in your calculation: Distance = 1000, Time Taken = 120.

Your tasks:

  1. Define a function called calcSpeed.
  2. Declare the variables distance and timeTaken inside the function using the values above.
  3. Calculate the speed using the formula.
  4. Return the calculated speed.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 4. ChapterΒ 3
single

single

Ask AI

expand

Ask AI

ChatGPT

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

close

bookChallenge: Calculating the Speed of a Car

Swipe to show menu

Task

Swipe to start coding

If we know the distance a car has traveled and the time it took to cover that distance, we can calculate its average speed using the formula:

Speed = Distance / Time Taken

The distance is measured in meters and the time in seconds.
Use the following values in your calculation: Distance = 1000, Time Taken = 120.

Your tasks:

  1. Define a function called calcSpeed.
  2. Declare the variables distance and timeTaken inside the function using the values above.
  3. Calculate the speed using the formula.
  4. Return the calculated speed.

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
single

single

some-alt