1. if/else



It says when 3 is inputed it comes out as true.

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


in javascript, a single equal sing means assign, not is equal


Your function is ignoring its argument, I doubt it'll be able to accurately tell whether the argument is odd or even without looking at it


Ok now I put
var isEven = function(number) {
if (isEven % 2 === 0){
return true;
} else {
return false;
}// Your code goes here!

but when two is input it returns false


so know you check if your function divided by two has a remainder of zero, does that make sense?


"isEven" is the name of your function. "number" is the name of the variable you want to check if it's even or odd. So "number" is the variable that should be inside the if condition


your error is in this step>> if(isEven % 2 = 0)
1-isEven is Boolean function equals to true or false what you did like :
if(true % 2 = 0) or if(false % 2 = 0)
2-you use this function to check any number you send, so your function should receive it and you should send it when you call this function
like this:
//i changed number to num in my code
var isEven = function(num) {
// Your code goes here!
if(num%2 === 0)
{return true;}
{return false;}
//the number that you will check
var num = Math.floor(Math.random()*100);
//calling your function
//you can send a specific number instead Math.floor(Math.random()*100)like


A post was split to a new topic: 1. if/else


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.