Beo
Three Magic
- Joined
- Aug 25, 2009
- Messages
- 9,074
- Solutions
- 1
- Reaction score
- 857
Can someone explain it to me further? I really get stuck with these... xd
Doing Codecadamy exercises. Stuck on this;
So I have to fill the code out with the answer, which I have no idea what it is. Hint isn't very helpful either lol.
I don't want the exact answer, I just want to understand it. Thanks.
Probably coz I'm so tired. Gonna sleep and try again tomorrow
Doing Codecadamy exercises. Stuck on this;
So why learn modulo? For one thing, it's good at testing divisibility. Consider 30 % 10. What does it return? There is nothing left over, so 0.
How about 9 % 3? Also 0.
200 % 100? You guessed it....2! Just kidding, it's also 0.
This is fun when we combine it with conditionals.
Edit line 3 so the correct prompts are displayed.
Code:
//An example of an if/else statement with modulo in the condition
if( ) {
console.log("The first number is even!");
} else {
console.log("The first number is odd!");
}
So I have to fill the code out with the answer, which I have no idea what it is. Hint isn't very helpful either lol.
I don't want the exact answer, I just want to understand it. Thanks.
Probably coz I'm so tired. Gonna sleep and try again tomorrow