Why we need to declare always a new variable?


Why the excercise does not accept the previously declared variable for project-buttons? The one you have used to present the OnClick listener. Like this:

var $projButtons = $(".projects-button").on("click", function() {

var $projs = $(".projects").toggle();

You can use it to toggle the class and it will work perfect. However this will not be accepted, you need to declare a new variable in order to get a green and continue. Like this:

var $projButtons = $(".projects-button").on("click", function() {

var $projs = $(".projects").toggle();
var $projButs = $(".projects-button").toggleClass("active");


==Q1== The code presented is not complete, with a missing } and )
==Q2== could you provide a link to the lesson....??


Yes, it is only a incomplete code fragment, I know. But, the idea is on the third line. First example is working fine, but not accepted by the test checker. You have to code it like in the second example to be able to continue. Why?


And the link i asked for ...??!




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