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

Glissez pour afficher le menu

book
Challenge: Calculating the Speed of a Car

Tâche

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 desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 4. Chapitre 3
Nous sommes désolés de vous informer que quelque chose s'est mal passé. Qu'est-il arrivé ?

Demandez à l'IA

expand
ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

book
Challenge: Calculating the Speed of a Car

Tâche

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 desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 4. Chapitre 3
Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Nous sommes désolés de vous informer que quelque chose s'est mal passé. Qu'est-il arrivé ?
some-alt