Linked Questions

9 votes
3 answers
20k views

Possible Duplicate: Does JavaScript have a range() equivalent? Is there a way to declare a range in Javascript/jQuery like we do in Python? Something like this: x = range(1,10) x = [1,2,3,4,5,...
5 votes
1 answer
10k views

Is it any way to create an array a selected size(for example 10) and immediately on the spot fill in it with some numbers specified pattern (1, 2, 3, OR 2, 4, 6 and so on) in one statement in JS? ...
Yellowfun's user avatar
  • 568
2 votes
5 answers
8k views

I want to design some arrays like [1..25] in JavaScript, but I don't want to do by hand ([1, 2, 3, 4, 5, 6, [...], 25]). How would you do?
-3 votes
4 answers
10k views

I've looked at similar questions but not seeing something that directly answers my question. I'm looking for the most efficient way to print odd numbers 1-100, without using any extra conditional ...
jwally's user avatar
  • 1
0 votes
3 answers
2k views

what is the fastest way to create array from number 17 to number 120? [17,18,20,...,118,119,120] I tried to use Array method but its start with 0 and slice from some resson cut the last numbers and ...
user avatar
6 votes
0 answers
4k views

In Java8, we can get a stream of numbers in a range like: IntStream.range(1, 3).forEach(System.out::println); IntStream.rangeClosed(1, 3).forEach(System.out::println); How can I get a array in JS ...
CaryNovA's user avatar
1 vote
2 answers
2k views

How can I very simply convert an number into an array without doing a for loop? Something like this: var days = 30; var days = days.toArray(); // Output - [1, 2, 3, 4, 5, 6, 7, 8, 9, ...] What I ...
Red's user avatar
  • 7,473
3 votes
2 answers
1k views

I want to know if it is possible to make a method that takes two integer values as parameters and returns them and all the numbers between then in an array. So for example if my method is function ...
RobStallion's user avatar
  • 1,733
0 votes
2 answers
3k views

Is there a simple way in TypeScript to generate an array of the first 10 integer numbers? Such as I would do with Matlab with x = 1:10.
Robb1's user avatar
  • 5,085
1 vote
3 answers
841 views

I want to know what is the equivalent code for the python's range(start,stop,step=1). If anyone knows, I am really grateful for the help.
1 vote
4 answers
1k views

I want to get array with the range [1,1.1,1.2 ...... 9.9,10] I wrote this code which returns me from 1.1 until 9.9 Is there a shorter way to get this range in JavaScript? Seems like lots of code. How ...
0 votes
1 answer
733 views

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 ...
Ghoyos's user avatar
  • 632
1 vote
3 answers
383 views

Is there a way to create an Integer range? In other languages, I can use Range(1, 9) to create [1, 2, ... 8] easily. Is there a simple way to create the list in JavaScript?
sof-03's user avatar
  • 2,505
0 votes
3 answers
96 views

The following typescript function seriesIncrementedBy5 returns an array with numbers starting from 5 to upperLimit with an increment of 5. Is there a way to replace this 5 lines of code with any ...
-2 votes
1 answer
101 views

I have a string representation of a numerical range var range = '6-14'; I want to create an array of integers represented by this range [6,7,8,9,10,11,12,13,14] I could implement this simple enough ...
Jeff's user avatar
  • 14.3k

15 30 50 per page
1
2 3 4 5 6