TIL a easier way to check for multiple OR statements
POSTED ON:
I nerd out about this stuff.
Essentially, it's turning a multiple conditional into a array, then array to see if it matches.
// longhand
if (x === 'abc' || x === 'def' || x === 'ghi' || x ==='jkl') {
//logic
}
//shorthand
if (['abc', 'def', 'ghi', 'jkl'].includes(x)) {
//logic
}
via Blessing Hirwa
Related TILs
Tagged: logic