Created
April 12, 2024 19:12
-
-
Save BideoWego/483a218f9d8b6edd6a187397aea19e51 to your computer and use it in GitHub Desktop.
Wanna FAFO what a jawn is? Use this javascript function!
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
/** | |
* Wanna FAFO what a jawn is? Use this function! | |
* @param {*} jawn The jawn. Any jawn. | |
* @returns {string} What the jawn is... | |
*/ | |
function whatIsThisJawn(jawn) { | |
let answer = 'Yo this jawn is'; | |
if (jawn === undefined || jawn === null) { | |
return `${answer} ${jawn}`; | |
} | |
return `${answer} an instance of ${jawn.constructor && jawn.constructor.name}`; | |
} | |
whatIsThisJawn(undefined); | |
//=> 'Yo this jawn is undefined' | |
whatIsThisJawn(null); | |
//=> 'Yo this jawn is null' | |
whatIsThisJawn(1); | |
//=> 'Yo this jawn is an instance of Number' | |
whatIsThisJawn('asdf'); | |
//=> 'Yo this jawn is an instance of String' | |
whatIsThisJawn({}); | |
//=> 'Yo this jawn is an instance of Object' | |
whatIsThisJawn([]); | |
//=> 'Yo this jawn is an instance of Array' | |
whatIsThisJawn(new Date()); | |
//=> 'Yo this jawn is an instance of Date' | |
whatIsThisJawn(new Set()); | |
//=> 'Yo this jawn is an instance of Set' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When you're can javascript, but you're also a philly local.