Um my code works perfectly, Codeacademy, Y U no like?


#1


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


Codeacademy keeps telling me that "Oops, try again. Looks like your function returns false when number = 2. Check whether your code inside the if/else statement correctly returns true if the number it receives is even." when I enter '3'

and "Oops, try again. Looks like your function returns false when number = 3. Check whether your code inside the if/else statement correctly returns true if the number it receives is odd." when I enter '2'

But neither of those are accurate. The code works. I think it must be bugged somehow. Does anyone have a code that works that I can plug in instead just to move on from this?


var userInput = prompt();

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

isEven(userInput);


#2

The function should take one parameter, number to which the conditional will return a boolean.

User input is not asked for, not expected.


#3

okie dokie, thanks for the response!


#4

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