Mario Won't Move


The picture will move left and up, but not down or right.

$(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:
				// Put our code here
				$('img').animate({top: "-=10px"}, 'fast');
			// Right Arrow Pressed
			case 39:
				// Put our code here
				$('img').animate({right: "-=10px"}, 'fast');
			// Down Arrow Pressed
			case 40:
				// Put our code here
				$('img').animate({bottom: "-=10px"}, 'fast');


animate() takes its reference from the top/left of the window. We cannot use right or bottom.

$('img').animate({left: "+=10px"}, 'fast');

$('img').animate({top: "+=10px"}, 'fast');


A post was split to a new topic: Controller of this exercise is broken


thank you that was really useful..

why does codecademy not mention that in its tutorials? that really confuses people...


That is something I cannot answer. This question comes up a few times a year so is well documented in the forums.