What is the problem with my script? When I execute it, the alert (line 2) gives me "100,200,300undefinedundefined", so is seems like 100,200,300 is interpreted as h1 when I would like it to be h1, h2 and h3 (with the commas).
function myanimation(h1,h2,h3) {
alert(h1 + h2 + h3);
$("#h1").animate({"left": h1});
$("#h2").animate({"left": h2});
}
var moves = new Array()
moves[1] = [100,200,300];
moves[2] = [300,200,100];
moves[3] = [-500,-300,0];
var i = 1;
function animatenow(){
myanimation(moves[i]);
i++;
}
$('#launch').click(function() {
setInterval(animatenow, 5000);
});