39. implement range()

JavaScript
Is this helpful ?

easy  - accepted / - tried

Can you create a range(from, to) which makes following work?

for (let num of range(1, 4)) {
  console.log(num)  
}
// 1
// 2
// 3
// 4

This is a simple one, could you think more fancy approaches other than for-loop?

Notice that you are not required to return an array, but something iterable would be fine.

Let's try to solve this problem within 10 minutes.

Discuss(50)