ahribori / daily-algorithm

매일 알고리즘 문제풀자
1 stars 1 forks source link

Staircase #7

Open ahribori opened 5 years ago

ahribori commented 5 years ago

https://www.hackerrank.com/challenges/staircase/problem

샵찍기 문제

   #
  ##
 ###
####

이런 모양으로 찍어야 된다.

ahribori commented 5 years ago
const staircase = n => {
  for (let i = 0; i < n; i++) {
    let line = '';
    for (let j = n; j >= 0; j--) {
      if (i >= j) {
        line += '#';
      } else {
        line += ' ';
      }
    }
    console.log(line);
  }
};