I Have this code where i keep getting the same error after trying everything. I have also checked other similar stackoverflow question but still no answer worked please can you help me out
ERROR: Uncaught SyntaxError: Unexpected end of input
Javascript
const colors = document.getElementsByClassName('s-colors');
for(var i = 0; i < colors.length; i++) {
colors[i].addEventListener('click', () => {
console.log(this.getAttribute("data-color"));
})
}
Html
<div class="pdt-color">
<h4>Color</h4>
<div class="colors">
<a href="javascript:void" class="s-colors" data-color="red"
style="background-color: red;"></a>
<a href="javascript:void" class="s-colors" data-color="black"
style="background-color: black;"></a>
<a href="javascript:void" class="s-colors" data-color="yellow"
style="background-color: yellow;"></a>
<a href="javascript:void" class="s-colors" data-color="blue"
style="background-color: blue;"></a>
</div>
</div>