Fix subtitlesMenu redeclaration in "Adding captions and subtitles to HTML video" tutorial #37128
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In the "Building a caption menu" section of the "Adding captions and subtitles to HTML video" tutorial, the
subtitlesMenu
variable is accidentally declared twice:Using this verbatim leads to the following error:
Uncaught ReferenceError: can't access lexical declaration 'subtitlesMenu' before initialization
. Removing theconst
forsubtitlesMenu
turns the statement from an unintended 2nd declaration to the intended initialization of the 1st declaration.Motivation
Readers who are going through this tutorial would be confused that using the tutorial code is leading to browser errors. This pull request will prevent confusion for future readers.
Additional details
The MDN tutorial is based on code from a tutorial by iandevlin, which uses the ECMAScript 5 syntax of
var
instead oflet
andconst
:While using
let
andconst
as above means 2 differentsubtitlesMenu
variables are stored, usingvar
means only 1subtitlesMenu
variable is stored and it is assigneddf.appendChild(document.createElement('ul'))
.Related issues and pull requests
Having done a quick search, it appears there are no related issues or pull requests.