I have a problem with this code:
function calculate() {
var input = document.getElementById("input").value;
var x = input;
for (var i = input; i > 1; i--) {
x += i;
}
var j = 1;
var k = 1;
var number = 1;
var output;
while (k < x) {
output = number.toString() + " ";
number += 1;
if (number = j) {
output += "\n";
j = 1;
k++;
}
}
document.getElementById("output").innerHTML = output;
}
<input id="input" type="number" />
<button onclick="calculate()">Calculate</button><br/>
<span id="output"></span>
It always returns 1. Can someone please help me?