I have the following code:
// Re-usable var's
var cc = []; // Main array
var div = document.getElementById('array');
var t = "";
var w = "";
var c = "";
// End
// Add element at first w/ push()
for(let i=0; i<=10; i++) {
cc.push(i);
w = document.getElementById("array");
c = document.createElement("p");
t = document.createTextNode("Push in array: " + i);
c.appendChild(t);
w.appendChild(c);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="array"></div>
</body>
</html>
How can I display the word " Push in array " only 1 time , but still show the 10 numbers , unmodified? the HTML
That something like:
Push in array: 1 2 3 4 5 6 7 8 9 10