Very confusing error statement, bug on page?


#1

https://www.codecademy.com/courses/javascript-beginner-en-qDwp0/0/1?curriculum_id=506324b3a7dffd00020bf661#

I have written the code so that it produces a "false" "true" and "This is not a number" response using a return statement- The code runs fine every time- However, I get an error code that reads

"Oops, Try Again. Looks like your code returns 'false' when number = 3. Check whether the code inside your if/else statement correctly returns true when the number is odd"

Whoa Nelly, what planet are we on? Cause I'm pretty sure the directions just asked me to return "true" when the the number was evenly divisible. You want me to return 'True' when the number is not evenly divisible??

Even when I switch the statements to satisfy the error message, the message remains saying it wants me to print 'true' when input is odd... Even though the console reads "true" when I call it for 3. Am I going crazy here or is there a bug on the page...??

... Also, the instructions are a little redundant and doesn't really ask you to use an 'else if' statement to determine if the input is a string or an integer. At least at this point. Maybe thats the next step?

I'm sure I'm missing something. Any help would be greatly appreciated!


Replace this line with your code. 

var isEven = function(number) {
    if (number % 2 === 0) {
        return "True"; 
    } else if (isNaN(number)) {
        return "This is Not a Number"
    } else {
        return "False";
    }  
};

isEven(3)


#2

This is assignment you're on at the moment:

Write an if / else statement inside the isEven function. It should return true; if the number it receives is evenly divisible by 2. Otherwise (else), it should return false;.

Make sure to return - don't use console.log()!

My code that work is:

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

#3

Yeah, I wrote that code before the I posted the other one here - it didn't work. I just re-wrote it and got same strange error message. The thing that confuses me is that the error statement doesn't match what is asked in the directions. Seems that there is something wrong with the page...

I tried skipping ahead, and even though my code works and prints the correct output, another error message comes up contradicting what was asked in the directions.


#4

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