Skip to content

Instantly share code, notes, and snippets.

@Icehunter
Created July 3, 2014 19:05
Show Gist options
  • Save Icehunter/5c3864b8aba4d8687345 to your computer and use it in GitHub Desktop.
Save Icehunter/5c3864b8aba4d8687345 to your computer and use it in GitHub Desktop.
my mind has been destroyed :)
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