I am making a simple text color changer. There seems to be no problems in the JS. I am getting an error in the console that says “at < anonymous >”. I basically need to know what means to fix it. This is using an external JS style sheet.
Here is my code
const paragraphI = document.getElementById('paragraph');
const colors = ['black', 'blue', 'green', 'purple'];
let j = 0;
setInterval(() => {
paragraphI.style.color = colors[j];
j = (j + 1) % colors.length;
}, 1000);
NOTE I am using “j” instead of “i” because I am already using “i” in another javascript function.
I tried changing function names and making sure there wasn’t an error in my html/css. The JS isn’t running and still getting the same error. I haven’t seen it before so it threw me off.