11/12: Filling Out the Cases


#1


Hi, I completed the lesson, but my code still does not work. When I press the a, s, d and w keys nothing happens. Is this a bug or is there a way to improve the code? Thanks!

jQuery Events: 11/12: Filling Out the Cases


SyntaxError: Unexpected token ')'. Expected an identifier as property name.


$(document).ready(function() {
    $(document).keydown(function(key) {
        switch(parseInt(key.which,10)) {
			// Left arrow key pressed
			case 37:
				$('img').animate({left:"-=10px"}, 'fast');
				break;
			// Up Arrow Pressed
			case 38:
				$("img").animate({top:"-=10px"}, "fast");
				break;
			// Right Arrow Pressed
			case 39:
				$("img").animate({left:"+=10px", "fast");
				break;
			// Down Arrow Pressed
			case 40:
				$("img").animate({top:"+=10px", "fast");
				break;
		}
	});
});


#2

case 39:
$("img").animate({left:"+=10px", "fast");  //you didn't close }

and

case 40:
$("img").animate({top:"+=10px", "fast"); // same here

#3

Oh ok, thanks for the help!

Really appreciate it!