๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

๐Ÿ“„ Random Number

Question Descriptionโ€‹

Implement a random() that takes a min and max and returns a random number between min and max.

The function should return a random integer between the min and max values.

TypeScript Versionโ€‹

function createRandomNumber(min: number, max: number): number {
if (min >= max) {
throw new Error('์ „๋‹ฌ๋œ min ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” max๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค');
}

return Math.floor(Math.random() * (max - min) + min);
}

console.log(createRandomNumber(0, 200)); // 0 ~ 199