FAQ: Code Challenges: JavaScript Fundamentals - truthyOrFalsy()

this is my code but it wont let me continue, I believe it to be correct however I’m still new so I don’t know.

After trying all sorts of convoluted crap, like pretty much all the incorrect solutions I’ve seen here, I found this via google and it works.

const truthyOrFalsy = value => { if (value) { return true } else if (!value) { return false } } console.log(truthyOrFalsy(0));

Truthy/Falsy seems so simple but it’s the hardest thing to grasp so far.

I am grateful for this exercise in particular because it gave me a reason to hunt down (and subsequently read up on) this way of writing arrow functions which I recalled seeing earlier but couldn’t remember the specifics. Posted here for anyone wanting a reminder - I think this was covered here in an earlier lesson?

Spoiler blur for those who want to work up to it.

const truthyOrFalsy = val => val ? true : false; console.log(truthyOrFalsy(0))