function invert(x) {
if (x === 0) {
return 'input was zero';
} else {
return 1 / x;
}
}
The function will still work using an if statement instead of an if...else statementfunction invert(x) {
if (x === 0) {
return 'input was zero';
}
return 1 / x;
}