javascript - Function Returning Square Brackets When Using Array Methods -
i've started exercise in chapter 4 of book called eloquent javascript. exercise asks me following:
"write range function takes 2 arguments, start , end, , returns array containing numbers start (and including) end."
however, when write following code:
function range(start, end) { array = []; (var = start; <= end; += 1) { array.push(i); } return array; } console.log(range(5, 2));
it returns square brackets ( [] ). know issue might be? bunch!
you passing range indexes in wrong order. cant go 5 2, need go 2 5
range(2,5)
Comments
Post a Comment