Guess the random number code flow

// Math Mathematic
// Math.random () function generates a random number a random range [0,1), not including 0 1 comprising, before the excluding packet
var r = Math.random () // by multiplied by a random number increased range
r = r * 100; // random number between [0,100)

// converted to an integer number
r = Math.floor (r); // put down the entire required fractional part of omitted [0,99]
// offset position can occur [1100] by adding a range of random numbers
R & lt = R & lt @ +. 1 [1100]
the console.log (R & lt)
between // [5.50] random number; 5-5-50-5 0-45
// // 0-45.444 5-45 + 0. 5 +
var A = Math.floor (Math.random () * 46 is) +5
the console.log (A)
// [60-70] [0,10]
Math.floor (Math.random () *. 11) +60

// [71-81] [0,10]
Math.floor (Math.random () *. 11) // +71 [0,11) 10.99 [71, 81]
// generates a random number a prompt to enter a number of guessing b big b> a B GUESS Math.floor = var (Math.random () * 100) + 1'd; // [1,100]
var INPUT; // digital input

do {
// INPUT into digital
input = prompt ( "Please enter the 1-100 integer number between: ")
the INPUT = * 1 the INPUT
IF (the INPUT> gUESS) {
Alert (" Sao years, do you think big ")
} the else IF (the INPUT alert ( "Sao years, do you think small")
}
} while (the INPUT = GUESS!); // digital inputs and to guess the numbers are not equal when it to execute a block of code do {}
// must be above while end of the loop, the condition is not satisfied while is over; input == guess condition is not established
alert ( "Sao years, congratulations you won the lottery, a million spring for dinner");

Guess you like

Origin www.cnblogs.com/baixuezhemei/p/11596453.html