Difference between 2 Javascript codes

Yes, destroy them all.

You also have some bad duplicate showPause and showSpeaker functions that contain code that’s similar to your existing handlers. Those bad functions must be removed too.

I just did.

Where?

They are the showPause and showSpeaker functions that have evt in their parameter list.

Delete…

  function showPause(evt) {
    var button = getPlayButton(evt.target);
    playButton(button);
  }

  function showSpeaker(evt) {
    var button = getPlayButton(evt.target);
    playButton(button);
  }

Here:

And, in the remaining showPause and showSpeaker functions, they both show and hide the same things. One of those two functions is misbehaving and doesn’t correctly show/hide the right things.

The pause speaker don’t interchange.

Ninja’d. :dark_sunglasses:

I instructed you on what to do about that in post #273

Done…

Hey - it works.

41.21
Undeclared ‘document’.

Undeclared ‘document’.
var playButtons = document.querySelectorAll(“.playButton”);

  var playButtons = document.querySelectorAll(".playButton");
   playButtons.forEach(function(button) {
     button.addEventListener("click", playButtonClickHandler);
   });

That would be a problem if the code wasn’t being run in a web browser. Scroll down to the bottom of the page and tell JSLint to assume that you are using a browser.

I forgot to checkmark browser.

If you don’t want to forget about it, you can use the following as the first line of code which tells JSLint to assume that you are using a browser.

/*jslint browser */

I usually only use jslint right before I decide to use a code to clean it up first.

I find that it helps to use an editor that tells me about JSLint problems while I write. That way problems are caught even before I knew I was making them.

1 Like

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