The task is to implement a range function.
The boilerplate code
function range(from, to) {
// your code here
}
Create an empty array to push the results into
const result = []
Use a for loop that starts at "from" and continues till it reaches "to"
for (let i = from; i <= to; i++) {
result.push(i)
}
The result array is returned. The final code is:
function range(from, to) {
// your code here
const result = [];
for(let i = from; i <= to; i++) {
result.push(i)
}
return result;
}
That's all folks!
Top comments (0)