Posted By

Sullan on 07/05/11


Tagged


Versions (?)

Single line if else condition


 / Published in: JavaScript
 

  1. var x = "True";
  2. var b = getBoolean(x);
  3. alert(b);
  4.  
  5. function getBoolean(s)
  6. {
  7. return s.toLowerCase()=='true'?true:false;
  8. }
  9.  
  10. // Another simple example
  11. var a = 11;
  12. a == 10 ? alert("true") : alert("false");

Report this snippet  

You need to login to post a comment.