Jangan gunakan if-else dan beralih di javascript, gunakan objek literal
const getValue = (value) => ({
[value == 1]: 'Value is 1',
[value > 1]: 'Value is greater than 1',
[value < 1]: 'Value is less than 1',
})[true]
console.log(getValue(2));
console.log(getValue(-1));
console.log(getValue(-1+2)); // expect 'Value is 1'
Worried Willet