“Zufälliger boolescher JavaScript” Code-Antworten

JavaScript erhalten zufällig Booleschen

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

Zufälliger boolescher 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 erhalten zufällig Booleschen

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

Ähnliche Antworten wie “Zufälliger boolescher JavaScript”

Fragen ähnlich wie “Zufälliger boolescher JavaScript”

Weitere verwandte Antworten zu “Zufälliger boolescher JavaScript” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen