Westonci.ca is the ultimate Q&A platform, offering detailed and reliable answers from a knowledgeable community. Connect with a community of professionals ready to provide precise solutions to your questions quickly and accurately. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.

write a program that asks the user how far they ran and then how long they ran and prints out their speed in miles per hour javascript

Sagot :

Answer:

var distance = prompt("How far did you run? in miles");

var time = prompt("How long did you run? in hours");

function calSpeed(miles, hours){

   var speed = miles / hours;

   console.log(speed,"m/h")

calSpeed(distance, time);

Explanation:

The javascript uses the prompt function to get user inputs for the distance and time variables. The calSpeed function calculates and prints out the speed of the runner with the arguments, distance and time.