In code below, setInterval
does not work as you would expect i.e to call function greet
after every 3s
. It calls greet
the first time and that too before 3s
.
name = "Superman";
function greet(name) {
alert("Hello " + name)
}
setInterval(greet(name), 3000);
Can any body tell me what am I doing wrong.
Thanks bt