Our challenge today is called "even or odd", we are going to create a function that will take an integer as an argument, inside the body of the function we are going to write code that will detect whether the passed in integer is a odd or even number.

Please complete that challenge yourself first before checking out my solution. Here is my solution below.

const even_or_odd = (num)=>{

    if(num % 2 == 0){
      return "even"
    }

    return "odd"
}

console.log(even_or_odd(6));
// output = even
console.log(even_or_odd(3));
// output = odd

The most important thing about the function above is the use of the modulus operator. The modulus operator gives you the remainder of a division. For example, 10 % 3 = 3. (You divide 10 by 3, the result is 3 and the remainder is 1). In the case of our function we are using the number 2 to detect whether the passed in integer is even or odd. If we divide a even number by 2, we will have no remainder, so that means the given number is an even number. But if we divide a odd number by 2, we will have a remainder, so in that case it means the passed in integer is a odd number.