14,427,436 members
Rate this:
See more:
Write an if....else statement that:

-prints "even" if the number is an even number
-prints "odd" if the number is an odd number

(use the % operator to determine if the number is odd or even)

What I have tried:

/*
* Programming Quiz: Even or Odd (3-2)
*
* Write an if...else statement that prints `even` if the
* number is even and prints `odd` if the number is odd.
*
* Note - make sure to print only the string "even" or the string "odd"
*/

// change the value of `number` to test your if...else statement

var number = 2;

if (number % 2 = 0 ); {console.log("even");} else {console.log("odd");

}
Posted
Updated 8-Jan-20 8:01am
0x01AA 8-Jan-20 12:38pm

And what is the problem?
Btw. the first semicolon and the equality operator are wrong. It should be
`if (number % 2 == 0 ) {....`
`if (number % 2 = 0 ); {....`

Rate this:

## Solution 1

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
Member 14710674 8-Jan-20 13:06pm

It wasn't for a grade. I'm simply teaching myself and I was stuck in the equation part. I already posted how far I had gotten.