Quantcast
Viewing latest article 1
Browse Latest Browse All 12

Answer by Troy Cura for Appending HTML string to the DOM

The answer to my Question was just this; a simple Map with an empty value; and all I can get is a very heavy answer and not precise. I wonder who closed my question... didn't even bother to read

"use strict"try{  const fruits = new Map([["Banana",""],["Apples", ""], ["Orange"," "]]);let text = "<h1>Fruits</h1>" +"<ul>";fruits.forEach(function(value, key){  text += "<li>" + key + value +"<br>" +"</li>" });text +="</li> ";document.getElementById('demo').innerHTML = text;}catch(err){ document.getElementById('theError').innerHTML = err;}

Viewing latest article 1
Browse Latest Browse All 12

Trending Articles