This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /first you need to find a parent element node | |
| const parent2 = document.querySelector("#parent-2") | |
| const child1Ofparent2 = parent2.childNodes[0] | |
| //this will return the child-3 node which is at the first index of parent2 | |
| const child2Ofparent2 = parent2.childNodes[1] | |
| //this will return the child-4 node which is at the second index of parent2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const ballBoundaries = () => { | |
| // Bounce off Left Wall | |
| if (ballX < 0 && speedX < 0) { | |
| speedX = -speedX | |
| } | |
| // Bounce off Right Wall | |
| if (ballX > width && speedX > 0) { | |
| speedX = -speedX | |
| } | |
| // Bounce off player paddle (bottom) |
OlderNewer