직사각형 별찍기

2020.07.29

process.stdin.setEncoding("utf8");
process.stdin.on("data", (data) => {
  const n = data.split(" ");
  const col = Number(n[0]),
    row = Number(n[1]);
  const str = `${"*".repeat(col)}\n`.repeat(row);
  console.log(str);
});
  • repeat메소드가 있으니 굳이 for문을 돌릴 필요가 없다.

  • 자바스크립트로 코딩테스트를 볼 때 곤란한 점 중 하나가 입력값 받는 형식인데, 이 사례를 참조해야겠다.
    (readline도 차차 보긴 해야...)

0개의 댓글