Let’s say the following is our start value −
var startValue=10;
Let’s say the following is our end value −
var endValue=20;
Use the for loop to fetch numbers between the start and end value −
Example
var startValue=10; var endValue=20; var total=''; function printAllValues(startValue,endValue){ for(var start=startValue;start < endValue ;start++){ total=total+start+","; } } printAllValues(startValue,endValue) var allSequences = total.slice(0, -1); console.log(allSequences);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo87.js.
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo87.js 10,11,12,13,14,15,16,17,18,19