Difference between 2 Javascript codes

I don’t see where those functions are being called anywhere.

Are the functions called within those functions defined?
(hide, show, play, pause)

Several of those functions already have a reference to the button, from the (button) parameter of the function, so the var button line in those functions needs to be removed.

1 Like

This one stays, the others get deleted.

function playButton(button) {
  var button = getButton(event.target);

Here, what’s next?

No, that one doesn’t stay either. Are you failing to see that the playButton already has (button) as the function parameter? The function already has button defined as a function parameter. Replacing that button with another definition of the same button is worse than useless. Not only does that var button line replace the button that’s passed in to the function, it is a needless confusion to all developers looking at the code.

And the var button line fails to work as well.

Get rid of it.

Look at the browser console for info about the next problem.

ReferenceError: showPause is not defined
[Learn More]
show:1:1
ReferenceError: showSpeaker is not defined
[Learn More]
show:1:1
ReferenceError: showPause is not defined
[Learn More]
show:1:1
ReferenceError: playButton is not defined
[Learn More]

Before you get to those, there’s a separate issue that occurs when you first load the page.
Fixing that first issue might help to solve those other ones.

This issue?

SyntaxError: missing ; before statement
[Learn More]
show:154:3

});
}());

I fixed it:

Was I supposed to delete one of those?

No, I don’t think that you were.

Then I didn’t fix it.

How are you supposed to know if it needs 1 or 2


});
}());

I just put it back:

What do you mean by 1 or 2? Spaces? Braces? Parenthesis? Semicolons? Newlines?

We can’t read your mind.

1 Like

For the ending tags.

Sometimes it’s just

}

Sometimes it’s this:

    });
  }());

Sometimes it’s just this:
}());

In general, every “opening” should be paired with a “closing”.

<>[]{}()

1 Like

I’m never going to get it. I just have to look at the many examples I have of working code.