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

Glissez pour afficher le menu

book
Challenge: Fixing the Speed Function

Tâche

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.

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 6
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: Fixing the Speed Function

Tâche

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.

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 6
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