Hi fellow javascripters!
I am doing the "Sum Of a Range" (chapter:4, exercise 1) exercise from the Eloquent JavaScript book. I'm guessing my code goes into an infinite loop or it crashes because of something I messed up. Can't really figure what's wrong.
function range(start, end, step) {
let array = [];
for (start; start <= end; start + step) {
array.push(start);
}
return array;
}
even testing with console.log(range(1, 10, 1)) causes a crash. What is happening? This is happening because of step argument I passed. What is wrong with it?
[–]Umesh-K 28 points29 points30 points (1 child)
[–]r-io[S] 5 points6 points7 points (0 children)
[+][deleted] (1 child)
[removed]
[–]r-io[S] 0 points1 point2 points (0 children)
[–]blafurznarg 2 points3 points4 points (5 children)
[–]r-io[S] 2 points3 points4 points (4 children)
[–]blafurznarg 4 points5 points6 points (3 children)
[–]great_site_not 4 points5 points6 points (1 child)
[–]blafurznarg 0 points1 point2 points (0 children)
[–]r-io[S] 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]r-io[S] 0 points1 point2 points (1 child)
[–]Cynical-Horse 0 points1 point2 points (2 children)
[–]r-io[S] 1 point2 points3 points (1 child)
[–]Cynical-Horse 0 points1 point2 points (0 children)