Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. /**
  2. * Truthy, Extends the Normal Truthy and makes it only true values.
  3. * Normal Truthy will be true if the value is defined.
  4. *
  5. * @author Noah Halstead <nhalstead00@gmail.com>
  6. * @param {string|number|boolean} value Something the Evaluate for the "TRUE" value.
  7. * @return boolean If the Value is a "TRUE" value.
  8. */
  9. function truthy(value){
  10. if (value === undefined) return false;
  11. if (!["string", "number", "boolean"].includes(typeof value)) return false;
  12. if(typeof value == "string") value = value.toLowerCase();
  13. if(value === "true" || value === "yes" || value === true || value === 1 || value === "1") return true;
  14. return false;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement