scrimba
Your personality in emojis
My Emojis - Pop and Shift - updated
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

My Emojis - Pop and Shift - updated
AboutCommentsNotes
My Emojis - Pop and Shift - updated
Expand for more info
index.js
run
preview
console
// Make the pop and shift buttons work as well
const myEmojis = ["👨‍💻", "⛷", "🍲"]
const emojiContainer = document.getElementById("emoji-container")
const emojiInput = document.getElementById("emoji-input")
const pushBtn = document.getElementById("push-btn")
const unshiftBtn = document.getElementById("unshift-btn")

function renderEmojis() {
emojiContainer.innerHTML = ""
for (let i = 0; i < myEmojis.length; i++) {
const emoji = document.createElement('span')
emoji.textContent = myEmojis[i]
emojiContainer.append(emoji)
}
}

renderEmojis()

pushBtn.addEventListener("click", function(){
if (emojiInput.value) {
myEmojis.push(emojiInput.value)
emojiInput.value = ""
renderEmojis()
}
})

unshiftBtn.addEventListener("click", function(){
if (emojiInput.value) {
myEmojis.unshift(emojiInput.value)
emojiInput.value = ""
renderEmojis()
}
})
Console
/index.html
-2:50