+ 2

JS_ Why does this code increment by 5 when I told it to do by 1

It's supposed to add a table cell when you click on the "+". Every time you click on it it should add a table cell. But it adds about 5 table cells at once. What's the problem? Sorry, I forgot to put the code https://code.sololearn.com/WaFZt9uKxWO1/#js

11th Sep 2019, 12:49 AM
Ginfio
Ginfio - avatar
4 Antworten
+ 1
https://code.sololearn.com/WM5WmrdsR8WJ/?ref=app
11th Sep 2019, 3:33 AM
Anthony Johnson
Anthony Johnson - avatar
+ 2
Jay Matthews it is in a loop, but I can't figure out why it's not working.
11th Sep 2019, 12:56 AM
Ginfio
Ginfio - avatar
+ 1
Jay Matthews I meant to put the code up with the question: https://code.sololearn.com/WaFZt9uKxWO1/#js
11th Sep 2019, 1:00 AM
Ginfio
Ginfio - avatar
0
Your for loop states that every time your loop is executed and th_names_count is less than 10 to increment it. And your next call is to increment again. So with that said you are incrementing it 2 times per loop. 10 ÷ 2 = 5
11th Sep 2019, 3:53 AM
Anthony Johnson
Anthony Johnson - avatar