-1

In ruby you can specify a range like:

(1...10).each do |num|
  puts num
end

or

(1...15).each do |num|
  puts num
end

is there a way to do something similar in JS without having to build a function that defines a range, such as:

function myRange() {
  let x = [1,2,3];
  return x;
}

Also the question on stack overflow "Does JavaScript have a method like “range()” to generate a range within the supplied bounds?" is the opposite of this question.

without <- keyword

Ghoyos
  • 604
  • 2
  • 7
  • 18

1 Answers1

3

Since it seems like your question is specifically whether there is an built-in method to do this and you don't accept any workarounds, the answer is no, there is no built-in js method to do this.

ivanibash
  • 1,461
  • 2
  • 14
  • 37