0

Why does this code say that "ageCounter()" is not defined?

var age = function ageCounter(){ if (age > 2){ alert("You are a child"); } else if (age < 3){ alert("You are a baby"); } } This is my javascript code, and when I run it, it doesn't work! Please help!

3rd Jul 2018, 1:30 PM
Coder Of Life
Coder Of Life - avatar
1 Odpowiedź
+ 3
Look at your code again, where are you actually passing the age? All you did here is assign your function into age variable, hence it's not working. To call it you will need to type age(); but still you wont get any results cuz you have no age defined anywhere. You could leave it like this and just pass an argument in the function. I think you should go back and go through functions chapter again.
3rd Jul 2018, 1:40 PM
damyco
damyco - avatar