Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Fixing the Speed Function | Mastering Functions
Introduction to JavaScript

Svep för att visa menyn

book
Challenge: Fixing the Speed Function

Uppgift

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 variables distance and timeTaken from the calcSpeed function.
  • Add two parameters called distance and timeTaken to the calcSpeed function.
  • Finally, call the calcSpeed function twice with the corresponding arguments:
    • 1000 meters, 120 seconds.
    • 1200 meters, 160 seconds.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 4. Kapitel 6

Fråga AI

expand
ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

book
Challenge: Fixing the Speed Function

Uppgift

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 variables distance and timeTaken from the calcSpeed function.
  • Add two parameters called distance and timeTaken to the calcSpeed function.
  • Finally, call the calcSpeed function twice with the corresponding arguments:
    • 1000 meters, 120 seconds.
    • 1200 meters, 160 seconds.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 4. Kapitel 6
Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Vi beklagar att något gick fel. Vad hände?
some-alt