“JavaScript boolean acak” Kode Jawaban

JavaScript mendapatkan boolean acak

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

JavaScript boolean acak

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 mendapatkan boolean acak

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

JavaScript acak boolean

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

JavaScript acak 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

Jawaban yang mirip dengan “JavaScript boolean acak”

Pertanyaan yang mirip dengan “JavaScript boolean acak”

Lebih banyak jawaban terkait untuk “JavaScript boolean acak” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya