scrimba
Your personality in emojis
My Emojis - Render the New Emoji to the Screen
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 - Render the New Emoji to the Screen
AboutCommentsNotes
My Emojis - Render the New Emoji to the Screen
Expand for more info
index.js
run
preview
console
// Render the updated myEmojis array in the mini-browser.

// One solution: wrap the code for rendering the emojis in a function and make sure it
// clears away old version of the array before it renders the updated one

const myEmojis = ["👨‍💻", "⛷", "🍲"]
const emojiContainer = document.getElementById("emoji-container")

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

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 = ""
console.log(myEmojis)
}
})
Console
[
"👨‍💻"
,
""
,
"🍲"
,
"🔥"
]
,
/index.html
-3:20