Filling Out the Cases: Can't finish excercise while code does work


#1



I can move Mario to all the directions, but I keep getting the following error: "Oops, try again. Make sure to press 'left', 'up', 'right', or 'down' to make your character move!".

$(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

I finished that just a minute ago. And I realized the "order" matters! You should press the key in correct order.
And it's 1. 'left' 2. 'up' 3. 'right' 4. 'down'. Try this out!


#3

It worked. Thanks a lot.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.