how to generate a random number in typescript code example

Example 1: javascript get random integer in given range

const randomInteger = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;

Example 2: typescript random number

/**
* Gets random int
* @param min 
* @param max 
* @returns random int - min & max inclusive
*/
getRandomInt(min, max) : number{
	min = Math.ceil(min);
	max = Math.floor(max);
	return Math.floor(Math.random() * (max - min + 1)) + min; 
}

Example 3: random function javascript

let object = random(0, 50);
// making "object" a random number between 0 and 50.

console.log(object);
// printing object in the console