i'm learning javascript , need write simple function display age, based on birth year. parameter can use year born , need call function. have far:
function myage(birthyear) { var year = new date().getfullyear(); return year() - (birthyear); } myage(1984);
i'm receiving error code not function, i'm not sure i'm doing wrong. thought call function @ end numerical year , calculate. or advice appreciated!
it seems have typo in function, instead of line,
return year() - (birthyear);
write,
return (year - birthyear);
here complete updated function,
function myage(birthyear) { var year = new date().getfullyear(); return (year - birthyear); } console.log(myage(1984));
Comments
Post a Comment