3

I am trying to write a simple code with using a loop, in console that will look like this.

01-2--3---4----5-----6------7-------

Ok i've got a answer, code should look like this

var input = 7;
var oputPut = "";
var executeLoop = function () {
    for (var i = 0; i <= input; i++) {
        oputPut += i;
        var count = i;
        while (count > 0) {
            oputPut += '-';
            count--;
        }
    }
}();
console.log(oputPut);

Thanks everyone! :)

Camel17
  • 31
  • 5

0 Answers0