Doubt with Floyd's Triangle

0

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?

    
asked by anonymous 10.05.2018 / 00:51

1 answer

0
___ erkimt ___ Doubt with Floyd's Triangle ______ qstntxt ___

I have a problem with this code:

<input id="input" type="number" />
<button onclick="calculate()">Calculate</button><br/>
<span id="output"></span>

<script>
function calculate() {

var input = document.getElementById("input").value;
var x = input;


  var string;
  var increm=1;
  var i;

for(i=0;i<x;i++){
  string = "";

  var j=0;

  while(j<= i){
        output += string + "    " + increm;
        j++;
        increm++;
}
output+= "<br>";
}

  document.getElementById("output").innerHTML = output;
}
</script>
<input id="input" type="number" />
<button onclick="calculate()">Calculate</button><br/>
<span id="output"></span>

<script>
function calculate() {

var input = document.getElementById("input").value;
var x = input;


  var string;
  var increm=1;
  var i;

for(i=0;i<x;i++){
  string = "";

  var j=0;

  while(j<= i){
        output += string + "    " + increm;
        j++;
        increm++;
}
output+= "<br>";
}

  document.getElementById("output").innerHTML = output;
}
</script>

It always returns 1. Can someone please help me?

    
______ ___ azszpr297803
%pre%     
___
10.05.2018 / 14:14