function compute(){
var n = Number(document.getElementById("input1").value); // takes in the input1 as a number and sets n to that value
if (isNaN(n)){ // checks if n is a number (assuming that if there’s no input the number is 0)
alert("input 1 is not a number"); // alerts the user
return; // exits the function
}
n = parseInt(n); // makes n into an integer by cutting off its decimal placevar
v = String(document.getElementById("input2").value); // assuming that it doesn’t matter if they type html code.
if (v == ""){ // checks if v is blank
alert("input 2 does not contain a valid value"); // alerts the user
return; // exits the function
}
var result = document.getElementById("result"); // makes result become the element with the id "result"
result.innerHTML = null; // makes result blank
for (var i = 0; i < n; i++){ // does the loop n times
for (var g = 0; g <= i; g++){ // does the loop i+1 times
result.innerHTML += v; // adds the value of v to result
}
result.innerHTML += "
";// inserts a break into result to create a new line
}}
// please type this into input 2: // actually this is a bit better: