truthyOrFalsy values

This function takes in any value and returns true if the value is truthy and false if the value is falsy.

const truthyOrFalsy = value =>{
if (value===0 || value===null || value===’’ || value===undefined || value===NaN){
return false
}
else return true
}

console.log(truthyOrFalsy(6))

//The code runs well, but the exercise solution says am wrong. I can’t find what is wrong with this code.

It could be something simple like the SCT expecting curly braces around return true.

if () {

} else {

}

So true!!
I was complicating things.

1 Like