Variables - nth-child not working


#1


Link for exercise: https://www.codecademy.com/courses/web-beginner-en-GfjC6/0/3?curriculum_id=50a3fad8c7a770b5fd0007a1#


I was unable to figure out the correct code and after reading serveral forum posts I still cannot get the code to work properly. Is there anyway this course can be transferred into the format the "Learn" courses are so the code is shown after a few wrong attempts instead of having to staff and continuously answer the same questions?

Code:

$(document).ready(function() {
    
    $target.fadeOut('fast');
    var $target = $('ol :nth-child(4)');
});


Replace this line with your code.


#2

first you fade out the target, then you define what the target is? Shouldn't this be the other way around? How can you fadeOut a target if you don't know what the target is

codecademy even shows this below the output window


#3

Hi stetim94 - thanks for the quick reply. I reordered and I can now move on.

Looking at the code logically rather than by function it makes sense that I need to define the target first before the fade. Are there any other instances or cases in which the functions need to go before variables or other items?


#4

logic and programming is closely related. Your code always needs to be logic :stuck_out_tongue:


#5

Hi stetim94 - understand now just jQuery is very different to me than the HTML and JS classes I took. Also are you saying all variables will always go above the functions just like in HTML and JS? Thanks!


#6

$target is just a variable, of course you need to define a variable before you can use it


#7

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