Answers for "js create a range of numbers"

0

javascript generate a random integer number in a range of numbers

const min = 1;
const max = 4;
const intNumber = Math.floor(Math.random() * (max - min)) + min;
console.log(intNumber); //> 1, 2, 3
Posted by: Guest on April-01-2020
13

range javascript

[...Array(5).keys()];
 => [0, 1, 2, 3, 4]
Posted by: Guest on May-20-2020
1

function range() as range js

function range(start, end) {
	/* generate a range : [start, start+1, ..., end-1, end] */
	var len = end - start + 1;
	var a = new Array(len);
	for (let i = 0; i < len; i++) a[i] = start + i;
	return a;
}
Posted by: Guest on March-09-2020

Code answers related to "js create a range of numbers"

Code answers related to "Javascript"

Browse Popular Code Answers by Language