Browse - Programming Tips - How can I make a random boolean value?

Date: 2014oct14
Language: javaScript

Q.  How can I make a random boolean value?

A.  Use Math.random() which returns a number between 0 and 1

function randomBool() { return Math.random() < .5; }
function exampleUse() { for (var i = 0; i < 100; i++) { console.log(randomBool()); } }