Hacker Rank- Staircase (Easy)

Link to code challenge
function staircase(n) { let count = n - 1; for (let i = "#"; i.length <= n; i += "#") { console.log(" ".repeat(count) + i); count--; } }

Without creating a new variable:

function staircase(n) { for (let i = "#"; i.length <= n; i += "#") { console.log(" ".repeat(n - i.length) + i); } }

Comments

Popular posts from this blog

Code Wars: Data Reverse (6 kyu)

Code Wars: longest_palindrome (6 kyu)

Code Wars: Find the odd int