I write a function that accepts an integer and returns a string - an even or non-even number.
function even_or_odd(number) { return number mod 2 ? "Odd" : "Even" } I do not understand what is wrong?
I write a function that accepts an integer and returns a string - an even or non-even number.
function even_or_odd(number) { return number mod 2 ? "Odd" : "Even" } I do not understand what is wrong?
There is no mod construct in JS. But there is % :
const even = n => !(n % 2); console.info(even(5)); console.info(even(4)); What language do you write? I see that there is a fraction of pascal mod .
So, to find out if the number is even on js , you need to do so
function even_or_odd(number) { return number % 2 === 0 ? "Odd" : "Even" } console.log(even_or_odd(3)); console.log(even_or_odd(2)); Source: https://ru.stackoverflow.com/questions/596170/
All Articles