I'm new to javascript, it must be very basic:
if (controllerName === ('about' || 'contact' || 'lessons')) {
res.render(controllerName + '.ejs', locals);
}
Only when controllerName=='about' I go inside, the rest of the cases I don't.
How do the or and === operate in this case ?
You structured it incorrectly. A fix would be
if (controllerName == 'about' || controllerName == 'contact' || controllerName == 'lessons') {
res.render(controllerName + '.ejs', locals);
}
The problem was that ('about' || 'contact' || 'lessons') evaluates to about since it is the first non-(null/undefined) value in the set. It seems like you want to compare controllerName to all three values so notice how my version of your code compares controllerName to all three values separately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With