+ 1
Why doesn't this work?
Read the JavaScript comments for this code. https://code.sololearn.com/WoOBKjaivtfE/?ref=app
9 Answers
+ 3
You have to..
https://code.sololearn.com/W6z1zG1eXZ47/?ref=app
+ 3
Daniel Cooper
You should know that OutTwo returns an array of all elements with class "myOutTwo".
Since it's an array, you can't just set a color for it, because Javascript won't know which particular element to apply the style to.
If you wanted to set the general color for ALL the elements, you should used a for loop, to loop through the entire array
+ 2
+ 2
Daniel Cooper Here you go.. an example. LOL
https://code.sololearn.com/Wa52fvyXyzNs/?ref=app
+ 2
Daniel Cooper It's for iterating all the class elements. LOL
+ 1
D'lite can you give me an example?
+ 1
D'lite What exactly does for(var i of OutTwo) do?
(Is new to coding)
+ 1
CalviŐ˛ But what is i? What does "of" do? I don't understand anything in this line of code except "for". xD