js
🧩 Syntax:
const links = [
{
link: "https://google.com",
title: "Google"
},
{
link: "https://facebook.com",
title: "Facebook"
},
{
link: "https://github.com",
title: "GitHub"
},
{
link: "https://youtube.com",
title: "YouTube"
}
]
const rootDiv = document.querySelector("#root")
for (let i = 0; i < links.length; i++) {
const {link, title} = links[i]
const aElem = document.createElement("a") // <a></a>
aElem.setAttribute("href", link) // <a href="{link}"></a>
aElem.innerText = title // <a href="{link}">{title}</a>
rootDiv.append(aElem)
}
a {
margin: 0 5px;
}