Question: .btn{border:1px solid black; padding:5px;display:inline-block} Distance Travelled Click the button to determine the distance travelled over time. What is the speed of the car in miles

Distance Travelled
Click the button to determine the distance travelled over time.
What is the speed of the car in miles per hour
How many hours has the car been travelling?
//
// The distance a vehicle travels can be calculated as follows:
//
// distance=speed X time
//
// For example, if a car travels at the speed of 40 miles per hour for three hours,
// the distance traveled is 120 miles. Write a program that asks the user for the speed of a
// vehicle (in miles per hour) and the time it has travelled in hourly increments.
//
// Express the distance travelled as a list of comma separated values.
//
// For example:
// 40,80,120,
//
// Define a function that uses a loop to produce the output as shown above.
//
// The function should take two parameters as input, a variable named "speed" and a variable named
// "miles" and produce a string of comma separated values.
//
// Notice that in the example given there a comma at the end of the list. This is expected in this code.
//
// If a user provides any input that is not a natural number, then the function should
// return the error message: "Bad data. Try again."
//
/////////////////////////////////////////////////////////////////////////////////
// Supporting functions start here. //
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Supporting functions end here. //
/////////////////////////////////////////////////////////////////////////////////
function distanceTravelled(speed,time){
/////////////////////////////////////////////////////////////////////////////////
// Insert your code between here and the next comment block. Do not alter //
// any code in any other part of this file. //
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Insert your code between here and the previous comment block. Do not alter //
// any code in any other part of this file. //
/////////////////////////////////////////////////////////////////////////////////
}
$('#btn_1').click(function(){
var speed = $('#textEntered1').val();
var hours = $('#textEntered2').val();
var message = distanceTravelled(speed, hours);
$('#textDisplayed1').html(message);
})
JavaScript loops Assignment06a THE PROBLEM: The distance a vehicle travels can be calculated as follows: distance=speed X time For example, if a car travels at the speed of 40 miles per hour for three hours, the distance traveled is 120 miles. Write a program that asks the user for the speed of a vehicle (in miles per hour) and the time it has travelled. The program should then express the distance travelled in hourly increments as a list of comma-separated values. For example: 40,80,120, Define a function that uses a loop to produce the output as shown above. The function should take two parameters as input, a variable named speed and a variable named miles. The function should return a string of comma separated values, with no extra spaces, exactly as shown. Notice that in the example given there a comma at the end of the list. This is expected in this assignment. If a user provides any input that is not a natural number, then the function should return the error message: "Bad data. Try again." HOT TIP: You can reuse your isNaturalNumber() function from a prior assignment to help you with your error trapping
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
