For example, the following code:
const plantNeedsWater = function(day){
day === 'Wednesday' ? return true : return false;
}
Results in a syntax error. Why is that?
For example, the following code:
const plantNeedsWater = function(day){
day === 'Wednesday' ? return true : return false;
}
Results in a syntax error. Why is that?
Just wrap the whole ternary in a return statement and you’re golden:
const plantNeedsWater = (day) => {
return (day === 'Wednesday' ? true : false);
};
console.log(plantNeedsWater("Wednesday"));
//true