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
andtimeTaken
from thecalcSpeed
function. - Add two parameters called
distance
andtimeTaken
to thecalcSpeed
function. - Finally, call the
calcSpeed
function twice with the corresponding arguments:1000
meters,120
seconds.1200
meters,160
seconds.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 4. Kapitel 6