I wrote the function to check if a given number is positive, negative, or zero. Is there a shorthanded way?
Is it possible to test the condition with map (using object to index the conditions)? i was inspired by second solution in this question but not sure how it applies here.
const numCheck = (num) => {
if (num == 0) {
return "zero";
} else {
return num > 0 ? "positive" : "negative";
}
};
const num1 = 3;
console.log(numCheck(num1));