-
-
Save AliceWonderland/528b3a3f562c860dbd9876f7d15d0058 to your computer and use it in GitHub Desktop.
3.4 Truthy created by smillaraaq - https://repl.it/GxZN/6
This file contains hidden or 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
| function isTruthy(arg){ | |
| var theType= typeof arg; | |
| var theBool= !!arg; //the original bool of the param | |
| var theMessage= ""; | |
| console.log(theType+" "+theBool); | |
| if(theType==="undefined"){ | |
| theMessage= theType+" is falsey"; | |
| }else if(theType==="null"){ | |
| theMessage= "The "+theType+" value is falsey"; | |
| }else if(theType==="boolean"){ | |
| var theBoolMessage=theBool?"truthy":"falsey"; | |
| theMessage= "The "+theType+" value"+theBool+" is "+ theBoolMessage; | |
| }else if(theType==="number"){ | |
| if(theBool){ | |
| theMessage= "The "+theType+" "+arg+" is truthy"; | |
| }else{ | |
| theMessage= "The "+theType+" "+arg+" is falsey (the only falsey number)"; | |
| } | |
| }else if(theType==="string"){ | |
| if(theBool){ | |
| theMessage= "The "+theType+" is "+ theBoolMessage; | |
| }else{ | |
| theMessage= "The empty "+theType+" is falsey (the only falsey string)"; | |
| } | |
| }else{ | |
| theMessage="do nothing"; | |
| } | |
| console.log(theMessage); | |
| } | |
| isTruthy(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment