Difference between 2 Javascript codes


#267

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.


#268

I just did.
https://jsfiddle.net/99j5wjuz/43/


#269

Where?


#270

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


#271

Delete.....

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

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

#272

Here:
https://jsfiddle.net/99j5wjuz/46/


#273

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.


#274

The pause speaker don't interchange.


#275

Ninja'd. :dark_sunglasses:

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


#276

Done...
https://jsfiddle.net/99j5wjuz/51/


#277

Hey - it works.


#278

41.21
Undeclared 'document'.

Undeclared 'document'.
var playButtons = document.querySelectorAll(".playButton");

https://jsfiddle.net/uzdyz3z3/2/

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

#279

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.


#280

I forgot to checkmark browser.


#281

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 */

#282

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


#283

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.


#284

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