how do i make the for each loop call the swap function when ever the blue button is clicked | Sololearn: Learn to code for FREE!

+4

how do i make the for each loop call the swap function when ever the blue button is clicked

note: the inbuilt IDE in sololearn does not recognise ...children(causing the cards to start from the 15th one), try running on personal ide to understand my question better https://code.sololearn.com/WITO1rlbovHf/?ref=app

1/27/2022 3:14:11 AM

loop

9 Answers

New Answer

+4

Solo's first reply is correct for the problem you're having with ...children, your code is trying to access the body of the document before is it is loaded. link below is quick read, it should help clear some up somethings https://www.sololearn.com/post/90825/?ref=app As far as your main problem the function swap is invoked when the blue button is clicked, the problem is with line 14. You need to change the logic of line 14 to include the skip button. https://code.sololearn.com/WKogRFAdof5c

+3

First, your script needs to wait until the html document is fully loaded: onload=()=>{ // your code }

+3

Yes, you have a lot of problems and you need to fix it one by one.

+3

Not a problem, glad I was able to help.

+2

ODLNT thank you so much

0

Solo that's not the problem

0

Ipang please help

0

Solo i also tried that before bringing it here, didn't work... i think the problem is a combination of...wrong looping, wrong skip button selection & wrong way of calling the swap function on each of the skip button

0

Solo if you got it to work please attach the code i'd like to see, thanks