+ 1

Why doesn't this work?

Read the JavaScript comments for this code. https://code.sololearn.com/WoOBKjaivtfE/?ref=app

12th Jul 2018, 6:04 AM
Daniel Cooper
Daniel Cooper - avatar
9 Respostas
12th Jul 2018, 6:11 AM
Calviղ
Calviղ - avatar
+ 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
12th Jul 2018, 6:15 AM
Dlite
Dlite - avatar
12th Jul 2018, 6:17 AM
Dlite
Dlite - avatar
12th Jul 2018, 6:19 AM
Calviղ
Calviղ - avatar
+ 2
Daniel Cooper It's for iterating all the class elements. LOL
12th Jul 2018, 6:50 AM
Calviղ
Calviղ - avatar
+ 1
D'lite can you give me an example?
12th Jul 2018, 6:16 AM
Daniel Cooper
Daniel Cooper - avatar
+ 1
D'lite What exactly does for(var i of OutTwo) do? (Is new to coding)
12th Jul 2018, 6:45 AM
Daniel Cooper
Daniel Cooper - avatar
+ 1
Calviղ But what is i? What does "of" do? I don't understand anything in this line of code except "for". xD
12th Jul 2018, 6:54 AM
Daniel Cooper
Daniel Cooper - avatar