DEV Community

duccanhole
duccanhole

Posted on

code every day with me

--DAY 2--
Hi, I am going to make #100DaysOfCode Challenge.Everyday I will try solve 1 problem from leetcode or hackerrank. Hope you can go with me until end.
This is 2nd day:
-Problem: Staircase
-Detail: https://www.hackerrank.com/challenges/staircase/problem
-My solution (javascript):

function staircase(n) {
    let line=[];
    line.length=n;
    line.fill(' ');
    for(let i=0;i<n;i++){
        line.shift();
        line.push('#');
        console.log(line.join(''));
    }
}
Enter fullscreen mode Exit fullscreen mode

--> If you have better solution or any question, please comment below. I will appreciate.

Top comments (0)