Answers for "js match within a range of numbers"

7

javascript print numbers in the given range

const range = (min, max) => [...Array(max - min + 1).keys()].map(i => i + min);
//or
const range = (min, max) => Array.from({ length: max - min + 1 }, (_, i) => min + i);

range(5, 10);   // [5, 6, 7, 8, 9, 10]
Posted by: Guest on July-02-2020
37

javascript get random number in range

function getRandomNumberBetween(min,max){
    return Math.floor(Math.random()*(max-min+1)+min);
}

//usage example: getRandomNumberBetween(20,400);
Posted by: Guest on July-23-2019

Code answers related to "js match within a range of numbers"

Code answers related to "Javascript"

Browse Popular Code Answers by Language