-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (39 loc) · 1.23 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const myEmojis = ["👨💻", "⛷", "🍲"]
function renderEmojis() {
const emojiContainer = document.getElementById("emoji-container")
emojiContainer.innerHTML = ""
for (let i = 0; i < myEmojis.length; i++) {
const emoji = document.createElement('span')
emoji.textContent = myEmojis[i]
emojiContainer.append(emoji)
}
}
renderEmojis()
const pushBtn = document.getElementById("push-btn")
pushBtn.addEventListener("click", function(){
const emojiInput = document.getElementById("emoji-input")
if (emojiInput.value) {
myEmojis.push(emojiInput.value)
emojiInput.value = ""
renderEmojis()
}
})
const unshiftBtn = document.getElementById("unshift-btn")
unshiftBtn.addEventListener("click", function(){
const emojiInput = document.getElementById("emoji-input")
if (emojiInput.value) {
myEmojis.unshift(emojiInput.value)
emojiInput.value = ""
renderEmojis()
}
})
const popBtn = document.getElementById("pop-btn")
popBtn.addEventListener("click", function(){
myEmojis.pop()
renderEmojis()
})
const shiftBtn = document.getElementById("shift-btn")
shiftBtn.addEventListener("click", function(){
myEmojis.shift()
renderEmojis()
})