Linked Questions
79 questions linked to/from Does JavaScript have a method like "range()" to generate a range within the supplied bounds?
9
votes
3
answers
20k
views
Range in Javascript/jQuery? [duplicate]
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
Fastest way to fill an array with multiple value in JS. Can I pass a some pattern or function to method fill insted of a single value in JS? [duplicate]
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?
...
2
votes
5
answers
8k
views
Create simple array "[x..y]" with JavaScript [duplicate]
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
Print odd numbers 1-100 (JavaScript - No extra conditional statements) [duplicate]
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 ...
0
votes
3
answers
2k
views
how to create array from 17 to 120 [duplicate]
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
user16106044
6
votes
0
answers
4k
views
Is there a JS function that acts like IntStream in Java? [duplicate]
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 ...
1
vote
2
answers
2k
views
Convert Number to Array without for loop JavaScript [duplicate]
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
A method that takes 2 integer values and returns an array. JavaScript [duplicate]
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 ...
0
votes
2
answers
3k
views
Generating an array of integers in TypeScript [duplicate]
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.
1
vote
3
answers
841
views
Equivalent of python's range in Javascript [duplicate]
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
JavaScript - Array with float from one to ten with decimals [duplicate]
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
Ruby like ranges in JavaScript? [duplicate]
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 ...
1
vote
3
answers
383
views
Is there a way to create an Integer range in JavaScript? [duplicate]
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?
0
votes
3
answers
96
views
Alternative code for filling an array with a series incremented by any value [duplicate]
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
Explode numerical range (e.g. '6-14') in Javascript [duplicate]
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