Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Truthy, Extends the Normal Truthy and makes it only true values.
- * Normal Truthy will be true if the value is defined.
- *
- * @author Noah Halstead <nhalstead00@gmail.com>
- * @param {string|number|boolean} value Something the Evaluate for the "TRUE" value.
- * @return boolean If the Value is a "TRUE" value.
- */
- function truthy(value){
- if (value === undefined) return false;
- if (!["string", "number", "boolean"].includes(typeof value)) return false;
- if(typeof value == "string") value = value.toLowerCase();
- if(value === "true" || value === "yes" || value === true || value === 1 || value === "1") return true;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement