javascript stairs code example
Example 1: js stairs algorithm
function staircase(n) {
let filledArray = new Array(n).fill(' ');
while (filledArray.indexOf(' ') !== -1) {
filledArray.shift();
filledArray.push('#');
console.log(filledArray.join(""));
n--;
}
}
Example 2: stairs javascriot
function staircase(n) { let filledArray = new Array(n).fill(' '); while (filledArray.indexOf(' ') !== -1) { filledArray.shift(); filledArray.push('#'); console.log(filledArray.join("")); n--; }}