benjaminvr

Codecademy - Truthy or falsy?

Jul 7th, 2021
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. It can be hard to keep track of what’s truthy or falsy in JavaScript. Write a function, truthyOrFalsy(), that takes in any value and returns true if that value is truthy and false if that value is falsy.
  3. */
  4.  
  5. let truthyOrFalsy = arg => {
  6.   if(arg) {
  7.     return true;
  8.   }
  9.   return false;
  10. }
  11.  
  12.  
  13. console.log(truthyOrFalsy(0));
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
Advertisement
Add Comment
Please, Sign In to add comment