Undefined function error javascript -


maybe i'm being stupid, following simple function, told there reference error, iseven being undefined:

var iseven = function(number) {     if (number%2=0) {         return true;     }     else {         return false;     }; }; 

is there i've missed i'm doing wrong?

you're using assignment operation in if clause, , not equality check, you'll want change second line from

number % 2 = 0

to this:

(number % 2) == 0

the error mentioned happening because initial error detailing improper syntax, if ignore , still try call function tell never defined (because during definition there error).


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jquery - Keeping Kendo Datepicker in min/max range -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -