More on Control in JS : 9.1


#1

What is wrong with this code?

54, the number used as isEven, when divided by 2, should come out with 27, making the statement true, returning true and passing the level. However, it is coming out as false. I have tried with other numbers such as 2,4,6,8,50, and 100. What is wrong?


#2

Hi inside your if statement add === 0 like that

if (isEven % 2 ===0)

#3

Thanks!!!! That worked!


#4

Hey hydra1516,

You're doing good work there! Unrelated to the question you have, I wanted to share a computer shortcut with you so you don't have to take the extra step of snapping a photo with your phone.

If you're on a mac hit the following hotkeys: "command" + "shift" + "4"

This creates a snipping tool for you to drag a box around the part of your screen you want to capture, then it lets you save it as file to upload easily.

If you're on a windows machine use the "snipping tool". The snipping tool can be found in the accessories folder located inside of all programs on your start menu. This works the same way as the mac shortcut, but you have to open it each time vs using the hot key. Keep at it with JavaScript, it looks like we are at the same level!

Reply back to me if you have any questions or if this doesn't work for you.


#5

var isEven = function(number) {
if (isEven % 2 === 0){
return true;
}
else {
return false;
}
}

isEven(12)

This is returning false for me - what am I missing here? Feel like I am going mad!


#6

Hi this part

if (isEven % 2 === 0)

You use the function isEven instead of the argument number.


#7

Got it. Damn I was blind to that -.- thank you very much.


#8

I know I am late to the chat but you really helped me too!