I'm starting to learn how to code and I guess this is really easy for you but it's been VERY hard for me to find out on how to do it.
I want to be able to add a number on and store that number and get a result like this:
Lets say I typed number 2, then 34, then 65 and 234.
Result would be like:
<integer>2</integer>
<integer>34</integer>
<integer>65</integer>
<integer>234</integer>
Do you see what i mean? I need to have the integer string plus whatever number I type and the result would need to add an br.
function myFunction() {
var x = parseFloat(document.getElementById("numb").value);
var result = document.getElementById("result");
var array = [];
array.push("<integer>" + x + "</integer>");
console.log(array);
result.innerHTML = array;
}
<h1>Integer</h1>
<h2>Enter number</h2>
<input type="number" id="numb">
<button id="submitbutton" type="button" onclick="myFunction()">Submit</button>
<h1>
<div>Result: <span id="result"> xxx </span></div>
</h1>
var array = [];outside the function You create a new array each time. I created you a snippet and fixed the spelling of Integerresult.innerHTML = array.join("<br/>");