Created
July 3, 2014 19:05
-
-
Save Icehunter/5c3864b8aba4d8687345 to your computer and use it in GitHub Desktop.
my mind has been destroyed :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var shouldTrueCount = 0; | |
var shouldTrue = [ | |
' ', | |
'a', | |
true, | |
1, {} | |
]; | |
for (var i = 0; i < shouldTrue.length; i++) { | |
if (shouldTrue[i]) { | |
shouldTrueCount++; | |
} | |
} | |
console.log('All that should be true are true: ' + (shouldTrueCount === shouldTrue.length)); | |
var shouldFalseCount = 0; | |
var shouldFalse = [ | |
'', | |
undefined, | |
null, | |
false, | |
0 | |
]; | |
for (var i = 0; i < shouldFalse.length; i++) { | |
if (!shouldFalse[i]) { | |
shouldFalseCount++; | |
} | |
} | |
console.log('All that should be false are false: ' + (shouldFalseCount === shouldFalse.length)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment