Not seeing the square links with javascript disabled

I need to leave a note on it so I know why it’s on there.

If there’s no note on it, I won’t remember why.

Why is that bad?

You told me, it’s just code laying around, not doing anything.

That comment will cause this problem to happen:

How is that a problem?

Aren’t you allowed to leave notes in the javascript?

Yes, you are allowed to leave notes. Doing that though is typically an admission that something is wrong with the code.

Is this better:

    function showPauseButton(button) {
        var pause = getPause(button);
        pauseAllButtons();
        hideAllButtons(button);
        show(pause);
        button.classList.add("active"); //Not needed yet.
        button.classList.add("activated");
    }

Nope, because should you add some CSS code that makes use of the active state, you then have JavaScript code that you’ve forgotten to remove the comment from.

There’s no need for that comment, remove it.

Is this better?

    function showPauseButton(button) {
        var pause = getPause(button);
        pauseAllButtons();
        hideAllButtons(button);
        show(pause);
        button.classList.add("active");
        button.classList.add("activated");
    }
    
    /* button.classList.add("active"); is not needed yet until merged.*/

Your future-self won’t thank you for the extra effort that you’re making for him. Do it though, and see what your future-self thinks about it later.

I don’t understand what’s wrong with leaving a note.

When writing code you may have some complex logic that is confusing, this is a perfect opportunity to include some comments in the code that will explain what is going on. Not only will this help you remember it later on, but if you someone else views your code, they will also be able to understand the code (hopefully)!

Another great thing about comments is the ability for comments to remove bits of code from execution when you are debugging your scripts. This lesson will teach you how to create two types of comments in JavaScript: single line comments and multi-line comments.

When the multiple sets of code are combined, you will be forced to remove that comment. But go ahead and add it if it makes you feel better. You’re only willfully ignoring the advice of an expert with years of experience in this.

1 Like

Is this better?

All the way at the bottom of the page?

No that’s not better, as it’s adding more details for you to needlessly worry about.

How am I supposed to remember it’s not being used yet?

Is this better?

    function showPauseButton(button) {
        var pause = getPause(button);
        pauseAllButtons();
        hideAllButtons(button);
        show(pause);
        button.classList.add("notactiveyet");
        button.classList.add("activated");
    }

You don’t remember that it’s not being used - free your mind.

But, in reality, it’s not being used in the code right now.


    function showPauseButton(button) {
        var pause = getPause(button);
        pauseAllButtons();
        hideAllButtons(button);
        show(pause);
        button.classList.add("notactive");
        button.classList.add("activated");
    }

That’s right, it’s not being used, and “notactive” will become even more confusing when you’ve forgotten about you did that in the first place. Leave it as “active”, and if you feel that you must do, also leave a comment

2 Likes

I was just going to say this, but you agree with me, it’s not being used at the moment.

Can you prove to me that it’s doing something?

 function showPauseButton(button) {
        var pause = getPause(button);
        pauseAllButtons();
        hideAllButtons(button);
        show(pause);
        button.classList.add("active");
        button.classList.add("activated");
    }

Thank you for helping me get this far.

1 Like

Sure, inspect the button b element, and each time you click on the button you’ll see in the HTML inspector show that active is added and removed from it.