“Wie man zufällig Boolean in JavaScript bekommt” Code-Antworten

JavaScript erhalten zufällig Booleschen

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

Wie man zufällig Boolean in JavaScript bekommt

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

Ähnliche Antworten wie “Wie man zufällig Boolean in JavaScript bekommt”

Fragen ähnlich wie “Wie man zufällig Boolean in JavaScript bekommt”

Weitere verwandte Antworten zu “Wie man zufällig Boolean in JavaScript bekommt” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen