The broken Task in javascript


#1



I just realized that this task is broken if you just make a error and do so the the just reads the if(number % 2) == true then is works.


This code is right but the task is broken so you get a error all the time by the task so you can't complete the task:
var isEven = function(number) {
  // Your code goes here!  

  if(number % 2) { 
      return true; 
  } 
  else if(number == 3) { 
    return false;
  }  
  else {  
      console.log(number % 2);
      return false; 
  }
   return number;
}; 
isEven(2); 


This code will make so you compelte the task: 
var isEven = function(number) {
  // Your code goes here!  

  if(number % 2) { 
      return true; 
  } 
  else if(num == 3) { 
    return false;
  }  
  else {  
      console.log(num % 2);
      return false; 
  }
   return number;
}; 
isEven(2);


#2

the exercise works fine, look at your if condition:

if(number % 2)

the remainder of even numbers is zero (false), the remainder of odd numbers is 1 (true), so if you don't compare the remainder with 0, you might want to return true inside your if, and false inside your else and everything works fine.


#3

show me plz. How to create the code


#4

uhm... have you tried implanting the suggestions i made? Or is there something you don't understand?


#5

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