+ 1

hello guys can someone give me an example in using Boolean in programme

1st Oct 2016, 9:28 AM
amir mahir
amir mahir - avatar
2 Answers
+ 2
Very often, in programming, you will need a data type that can only have one of two values, like YES / NO ON / OFF TRUE / FALSE JS Boolean(10 > 9) // returns true Or even easier: (10 > 9) // also returns true 10 > 9 // also returns true Boolean.prototype.myColor = function() { if (this.valueOf() == true) { return "green"; } else { return = "red"; } }; var a = true; var b = a.myColor(); The value of b is now: green
1st Oct 2016, 11:42 AM
Exklibur
Exklibur - avatar
0
<!-- true or false is a boolean value -->
1st Oct 2016, 10:49 AM
James Mackie
James Mackie - avatar