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


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');
			// Up Arrow Pressed
			case 38:
				$('img').animate({top: "-=10px"}, 'fast');
			// Right Arrow Pressed
			case 39:
				$('img').animate({left: "+=10px"}, 'fast');
			// Down Arrow Pressed
			case 40:
				$('img').animate({top: "+=10px"}, 'fast');


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!


It worked. Thanks a lot.


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