scrimba
Frontend Career Path
Making websites interactive
Chrome Extension
Get the leads from localStorage
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

Get the leads from localStorage
AboutCommentsNotes
Get the leads from localStorage
Expand for more info
index.js
run
preview
console
let myLeads = []
const inputEl = document.getElementById("input-el")
const inputBtn = document.getElementById("input-btn")
const ulEl = document.getElementById("ul-el")

// Get the leads from the localStorage
// Store it in a variable, leadsFromLocalStorage
// Log out the variable

inputBtn.addEventListener("click", function() {
myLeads.push(inputEl.value)
inputEl.value = ""
localStorage.setItem("myLeads", JSON.stringify(myLeads) )
renderLeads()

// To verify that it works:
console.log( localStorage.getItem("myLeads") )
})

function renderLeads() {
let listItems = ""
for (let i = 0; i < myLeads.length; i++) {
listItems += `
<li>
<a target='_blank' href='${myLeads[i]}'>
${myLeads[i]}
</a>
</li>
`
}
ulEl.innerHTML = listItems
}
Console
/index.html
-3:50