This forum is now read-only. Please use our new forums! Go to forums
I have no clue whats wrong with my code.
var isEven = function(number){
if(isEven % 2 === 0){return true;}
else{return false;}
};
isEven(4);
Answer 50c11a7b432535ae66000b27
3 votes
Your problem is that you put the name of the function in your if statement. You need to swap this for the ‘place holder variable’. That is what ever is between brackets of the function. In this case it is “number”. This temporary variable then gets swapped for whatever number you enter between the brackets when you call the function.
e.g.
var isEven = function(temporaryVariable) {
if(temporaryVariable % 2 === 0){
return true;
}
else{
return false;
}
};
isEven(4);
``//temporaryVariable gets swapped for the number 4. Then it runs the function with the number 4 instead.
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
3 comments
Thank you it works now.
best explanation I’ve seen about this (personally)
Thanks for the help, I had the exact same problem and this was the first one I tried…. thanks :)