“JavaScript acak boolean” Kode Jawaban

JavaScript mendapatkan boolean acak

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

JavaScript acak boolean

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

Pertanyaan yang mirip dengan “JavaScript acak boolean”

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

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya