JavaScript method to return random number in a range (exclusive of the min limit)

Took 2 minutes and 6 seconds to code JavaScript method to return random number in a range exclusive of the min limit. Here is the code snippet.

Code:

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

x = randomMaxInclusive(0, 10)
document.write(x);

Result:

10

1 comment:

  1. Casino games, slots, table games - Tricktactoe
    A modern 스포츠 토토 판매점 찾기 샤오 미 casino is all about entertaining the player. Slots, table 스포츠토토 샤오미 games, and sportsbook games 동행복권 먹튀 were all there to offer 스포츠토토 광고 샤오미 to you in a 넥스트 벳 more realistic

    ReplyDelete

Coding for Kids

What is coding? In coding we build a program to do a specific task for us. Code: A code is a set of computer instructions and when you will ...