()
| 1 | function animation () { |
| 2 | |
| 3 | const colors = ["2196F3", "e91e63", "ffeb3b", "74ff1d"]; |
| 4 | |
| 5 | const section = document.querySelector("section"); |
| 6 | const square = document.createElement("span"); |
| 7 | const star = document.createElement("i"); |
| 8 | |
| 9 | star.classList.add("fas"); |
| 10 | star.classList.add("fa-star"); |
| 11 | |
| 12 | let size = Math.random() * 100; |
| 13 | |
| 14 | star.style.height = 20 + size + "px"; |
| 15 | star.style.width = 20 + size + "px"; |
| 16 | |
| 17 | star.style.top = Math.random() * innerHeight + "px"; |
| 18 | star.style.left = Math.random() * innerWidth + "px"; |
| 19 | |
| 20 | // const randomColor = Math.floor(Math.random()*16777215).toString(16); |
| 21 | let randomColor = colors[Math.floor(Math.random()*4)]; |
| 22 | star.style.color = "#" + randomColor; |
| 23 | |
| 24 | section.appendChild(star); |
| 25 | |
| 26 | size = Math.random() * 20; |
| 27 | |
| 28 | square.style.height = 20 + size + "px"; |
| 29 | square.style.width = 20 + size + "px"; |
| 30 | |
| 31 | square.style.top = Math.random() * innerHeight + "px"; |
| 32 | square.style.left = Math.random() * innerWidth + "px"; |
| 33 | |
| 34 | randomColor = colors[Math.floor(Math.random()*4)]; |
| 35 | square.style.backgroundColor = "#" + randomColor; |
| 36 | |
| 37 | section.appendChild(square); |
| 38 | |
| 39 | setTimeout(function() { |
| 40 | section.removeChild(square); |
| 41 | section.removeChild(star); |
| 42 | }, 5000); |
| 43 | } |
| 44 | |
| 45 | setInterval(animation,100); |
nothing calls this directly
no outgoing calls
no test coverage detected