Filling out the Cases: Won't validate variable


#1


https://www.codecademy.com/courses/web-beginner-en-JwhI1/2/3?curriculum_id=50a3fad8c7a770b5fd0007a1#


The code works fine in the preview window, but the exercise won't validate it because I used a variable. Bug? "Oops, try again. Did you call the .animate() function on your $('img') for each of the three additional cases?"


$(document).ready(function() {
    var img = $('img');
    $(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

Not a bug. The SCT is not accepting the variable. Use the pattern that was given in the first case.


#3

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