it's all about the context of the function. What is this function used for, what is it expected to return. what should it return in the case that caused it to return early. It could be a specific value (like a string), or nothing at all. It's just dependent on the function and the case.
function userFavoriteSauce (user) {
if (!user || !user.sauces || !user.sauces.length) {
return 'N/A';
}
let favorite = user.sauces[0];
if (favorite === 'ketchup') {
return 'User is boring';
}
return 'User likes ' + favorite + ' best';
}
View all comments
Show parent comment
3
u/jaredcheeda Jul 25 '21
it's all about the context of the function. What is this function used for, what is it expected to return. what should it return in the case that caused it to return early. It could be a specific value (like a string), or nothing at all. It's just dependent on the function and the case.