I don't know who closed this question; but clearly it was never answered; maybe just to satisfy all question that are posted in this site; but clearly it did not match my question:: what a limp nodes is this...
But the Answer to this is a Map with empty key:
"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;
}
I was able to get an output with console.log with forEach but not with document.getElementById; also cant do with template literals on this... can somebody see or check this out or; this is something we need to improve with JS and to what ES?
sample below is stuck with one array result only and it did not loop, but at least.
<javascript>
"use strict"
try{
const cars = new Array("Saab", "Volvo", "BMW");
cars.sort;
let theResult = document.getElementById('demo');
cars.forEach(car => { theResult.innerHTML =car});
}
catch(err){
document.getElementById('theError').innerHTML = err;
}
</javascript>
Here is the HTML
<html>
<head>
<title></title>
</head>
<body>
<p id ='demo'>
<p id ='theError'>
</body>
</html>
Fruits
" + ""; fruits.forEach(function(value, key){ text += "- " + key + value + "
" });
text +=" ";
document.getElementById('demo').innerHTML = text;
}
catch(err){
document.getElementById('theError').innerHTML = err;
}
– Troy Cura Oct 14 '22 at 12:18" + "