11. Filling out cases, code not accepted


#1


Hello everyone! I'm having trouble getting this code to pass. When I run it, Mario moves up, down, right and left but the exercise won't pass :frowning:

Has anyone else encountered this? My code is included below.


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


#2

Your code looks fine and passes on my side,

Have you tried using another browser ?

What error are you getting ?


#3

I've tried using both chrome and edge. Might give Firefox a bash now.

The error that I'm getting is "Oops, try again. Make sure to press 'left', 'up', 'right', or 'down' to make your character move!"

I am pressing the keys required, do I need to press them a certain amount of times to pass?


#4

I'm not sure about the exact amount of times, I would say to be safe try five all ways !


#5

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