Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Fixing the Speed Function | Section
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
JavaScript Essentials for Beginners - 1768407374405

bookChallenge: Fixing the Speed Function

Task

Swipe to start coding

Previously, we created a calcSpeed function for calculating the average speed of a car.

Now you need to fix the function so that it can accept values from outside of the function.

  • Remove the local variables distance and timeTaken inside the function.
  • Add two parameters named distance and timeTaken inside the parentheses of the calcSpeed function.
  • Finally, call the calcSpeed function twice with the corresponding arguments:
    • 1000 meters, 120 seconds.
    • 1200 meters, 160 seconds.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 50
single

single

Ask AI

expand

Ask AI

ChatGPT

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

close

bookChallenge: Fixing the Speed Function

Swipe to show menu

Task

Swipe to start coding

Previously, we created a calcSpeed function for calculating the average speed of a car.

Now you need to fix the function so that it can accept values from outside of the function.

  • Remove the local variables distance and timeTaken inside the function.
  • Add two parameters named distance and timeTaken inside the parentheses of the calcSpeed function.
  • Finally, call the calcSpeed function twice with the corresponding arguments:
    • 1000 meters, 120 seconds.
    • 1200 meters, 160 seconds.

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 1. Chapter 50
single

single

some-alt