Question: This question relates to Javascript. Could you please show me how I can fix my code? I want a user to be able to enter
This question relates to Javascript.
Could you please show me how I can fix my code? I want a user to be able to enter a start number and a end number and my function to add all of these numbers to an array called userArray. I want to then print the contents of the array. Please show me how my code can be fixed so it works.
// The sum of a range
start = prompt("what is the start: ");
end = prompt("what is the end: ");
function rangeCal(start, end){
var userArray = [];
for(i=start; i<=end; i++){
userArray.push(i);
}
return userArray;
}
rangeCal(start, end);
document.writeln(userArray)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
