i want to check if a number is even by use of function and return in Javascript. here goes my code. It should return true when number is even otherwise it should return false.
var isEven = function(number) {
if(number%2 === 0) {
return "true";
} else {
return "false";
}
};
the code doesn't work. Instead it works when the quotation marks ( "...") around true and false are removed. Why? I mean the words true and false are strings, hence should be included inside quotation marks. please help,
trueandfalseare booleans, not strings.function isEven (num) { return num % 2 === 0 }.