Challenge: 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 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.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 4. ChapterΒ 6