Question: This is a Javascript code. Could you please show me why my code is not working. It was working until I added the step. //
This is a Javascript code. Could you please show me why my code is not working. It was working until I added the step.
// THE SUM OF A RANGE
var rangeNums = [];
var i, start, end, step;
var rangeTotal = 0;
function range(start, end, step){
for(i=start;i<=end;i=i+step)
rangeNums.push(i)
return rangeNums;
}
function rangeSum(rangeNums){
for(i=0;i rangeTotal = rangeTotal + rangeNums[i]; } return rangeTotal; } start = parseInt(prompt("what is the start number: ")); end = parseInt(prompt("what is the end number: ")); step = parseInt(prompt("what is the step between the values: ")); range(start,end,step); console.log(rangeNums); rangeSum(rangeNums); console.log(rangeTotal);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
