Generate a Range of Numbers

#codesnippet #javascript

Similar to numpy's arange(), this generates a range of numbers with defined start, stop (inclusive), and step between each value.

function genRange(start, stop, step) {
  const range = []
  for(let i = start; i <= stop; i += step) {
    range.push(i)
  }
  return range
}