Check the principles of minimalist code in the [intro to the first challenge] (https://edabit.com/challenge/nEdLGbAZQ5LaiumP6).
In the Code tab you will find a code that is missing a single character in order to pass the tests. However, your goal is to submit a function as minimalist as possible. Use the tips in the tips section below.
Write a function that returns the boolean true if the given number is zero, the string "positive" if the number is greater than zero or the string "negative" if it's smaller than zero.
Executing a return will effectively end your function.
For example, the code:
function compare_to_100 (x) {
if (x > 100) {
return "greater"
} else if (x < 100) {
return "smaller"
} else {
return "equal"
}
}
Can be simplified to:
function compare_to_100 (x) {
if (x > 100) return "greater"
if (x < 100) return "smaller"
return "equal"
}
x is greater than 100, JavaScript will not execute the code past the first return.x is smaller than 100, JavaScript will not execute the code inside the first if statement or past the second return.x is equal to 100, JavaScript will not execute the code inside the two if statements.return inside your if statement.