You are viewing a single comment's thread. Return to all comments →
With a bit less overhead of creating 2 new Arrays in each loop:
var spaces = Array(n + 1).join(' '); var sharps = '#'; for (var i = 0; i < n; i++){ console.log(spaces + sharps); spaces = spaces.split(0, -1); sharps = sharps + '#'; }
Seems like cookies are disabled on this browser, please enable them to open this website
Staircase
You are viewing a single comment's thread. Return to all comments →
With a bit less overhead of creating 2 new Arrays in each loop: