Skip to content

Commit ae35e91

Browse files
committed
Added Js file to my repo
Using SetInterval() Method to iterate through colours with JavaScript
1 parent b687814 commit ae35e91

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# Using SetInterval() Method to iterate through colours with JavaScript
22
Wonderful project been developed by myself to help the community to iterate through colours and display or change the color of an element after 2sec.
3+
4+

input.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
let mainDisplay = document.getElementById("main")
2+
let displayMyColor =["red","blue","pink","yellow","purple","green","indiego","orange","lemon","skyblue"]
3+
let element =0
4+
setInterval(() => {
5+
mainDisplay.style.color = `${displayMyColor[element]}`
6+
7+
element++
8+
if(element >= displayMyColor.length){
9+
element=0
10+
11+
}
12+
13+
14+
15+
}, 2000)

0 commit comments

Comments
 (0)