Can someone please show me how to remove this error from appearing in jslint?
How do I disable it?
This does not work: /*jslint for:true*/
I was told: https://jsfiddle.net/xrs21efw/
The correct solution is to use forEach method of the NodeList instead
of for loop.
function onYouTubeIframeAPIReady() {
let playerVarsList = {
"0": {
playerVars: {
playlist: "0dgNc5S8cLI,mnfmQe8Mv1g,-Xgi_way56U,CHahce95B1g"
}
},
"3": {
videoId: "0dgNc5S8cLI"
},
"5": {
playerVars: {
list: "PLYeOyMz9C9kYmnPHfw5-ItOxYBiMG4amq",
listType: "playlist"
}
},
"7": {
playerVars: {
end: 1800,
playlist: "0dgNc5S8cLI,mnfmQe8Mv1g,-Xgi_way56U,CHahce95B1g",
start: 150
}
}
};
//to add the player to all the play buttons
const totalP = document.querySelectorAll("[data-container=\"play1\"]");
//looping over all the play buttons and adding player to that
for (let i = 0; i < totalP.length; i++) {
players.add(".playSingle" + i, (playerVarsList[i] || {}));
}
players.add(".playInitial", {});
}
>Solution :
try the following:
totalP.forEach((_, index) => {
players.add(".playSingle" + index, (playerVarsList[index] || {}));
})

