Skip to content

Instantly share code, notes, and snippets.

@wiledal
wiledal / template-literals-3-for-loops.js
Last active January 1, 2025 06:18
Template Literals example: For loops
/*
Template literals for-loop example
Using `Array(5).join(0).split(0)`, we create an empty array
with 5 items which we can iterate through using `.map()`
*/
var element = document.createElement('div')
element.innerHTML = `
<h1>This element is looping</h1>
${Array(5).join(0).split(0).map((item, i) => `