“Losowy boolean JavaScript” Kod odpowiedzi

JavaScript zdobądź losowy boolean

const randomBoolean = () => Math.random() >= 0.5;
Batman

Losowy boolean JavaScript

console.log(Math.random() < 0.1); //10% probability of getting true
console.log(Math.random() < 0.4); //40% probability of getting true
console.log(Math.random() < 0.5); //50% probability of getting true
console.log(Math.random() < 0.8); //80% probability of getting true
console.log(Math.random() < 0.9); //90% probability of getting true
Mehedi Islam Ripon

JavaScript zdobądź losowy boolean

const randomBoolean = () =>{
  Math.ceil(Math.random() >= 0.5)
}
Code_Breaker

JavaScript Random Boolean

var random_boolean = Math.random() < 0.5;
Coding Grandma

JavaScript Random Boolean

// Example
console.log(Math.random() < 0.1); //10% probability of getting true
console.log(Math.random() < 0.4); //40% probability of getting true
console.log(Math.random() < 0.5); //50% probability of getting true
console.log(Math.random() < 0.8); //80% probability of getting true
console.log(Math.random() < 0.9); //90% probability of getting true
 Run code snippet
Helpless Horse

Odpowiedzi podobne do “Losowy boolean JavaScript”

Pytania podobne do “Losowy boolean JavaScript”

Więcej pokrewnych odpowiedzi na “Losowy boolean JavaScript” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu