Filling Out the Cases


#1

QQ截图20170816162612

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

the yellow error always tell me :mixed the tab and spaces
what is wrong ?
thanks


#2

There is nothing wrong with your code.
it’s just the indentation

write your code below the comment (//Put our code here) or replace the comment with your code.


#3

@rcodeman
thank you
i tried it again
this is code :slight_smile:
but it dinot work yet .

$(document).ready(function() {
$(document).keydown(function(key) {
switch(parseInt(key.which,10)) {
// Left arrow key pressed
case 37:
$(‘img’).animate({left:"-=10px"}, ‘fast’);
break;
case 38:$(‘img’).animate({top:"-=10px"},‘fast’);
break;
case 39:
$(“img”).animate({left:"+=10px"},“fast”);
break;
case 40:
$(“img”).animate({top:"+=10px"},“fast”);
break;
}
});
});


#4

i am confused for this quiz
i changed the browser ,firefox.google chrome,even i copied the code of another.
but it doesnot work ,i had stopped here for 2days

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

$(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:
// Put our code here
$(‘img’).animate({top: “+=10px”}, ‘fast’);
break;
}
});
});

it shows :slight_smile:
Oops, try again. Please follow the instructions on the Full Preview page to test your code.

who can help me ?thanks


#5

who can explain the
switch**(parseInt(key.which,10)**)
what is it ?which useful or no?
thanks


#6

After clicking on the save & submit button follow the instruction next to back to editor button.

and here

switch (parseInt(key.which,10)) {

parseInt() function parses a string argument and returns a integer of the specified radix(the base in mathematical numeral systems)
for more details go to docs:


key.which property indicates the key or button that was pressed.


#7

thanks
having tried several times.
i gave up this quiz …tired …
anyway ,thanks
i begin to do another exercise .


#8

The coding area is a bit quirky, its best to copy the whole line 6 (even the blank spaces that represent the tabs before the code) to the very beginning of each of the lines 8,12 and 16. This then eliminates the yellow ‘tab and spaces’ error and the program executes correctly.


#9

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