I am having trouble understanding the usage of brackets in \"for\" loops and \"if\" statements in Javascript. I have seen syntax in Javascript where there is brackets and where
Without brackets only the next statement is affected whereas with brackets everything inside the brackets is affected.
To add brackets to the loop and have it work exactly the same, just add them around the next statement:
function range(upto) {
var result = [];
for (var i = 0; i <= upto; i++) {
result[i] = i;
}
return result;
}