/*
https://school.programmers.co.kr/learn/courses/30/lessons/12922

๋ฌธ์ œ ์„ค๋ช…
๊ธธ์ด๊ฐ€ n์ด๊ณ , "์ˆ˜๋ฐ•์ˆ˜๋ฐ•์ˆ˜๋ฐ•์ˆ˜...."์™€ ๊ฐ™์€ ํŒจํ„ด์„ ์œ ์ง€ํ•˜๋Š” ๋ฌธ์ž์—ด์„ ๋ฆฌํ„ดํ•˜๋Š” ํ•จ์ˆ˜, solution์„ ์™„์„ฑํ•˜์„ธ์š”. ์˜ˆ๋ฅผ๋“ค์–ด n์ด 4์ด๋ฉด "์ˆ˜๋ฐ•์ˆ˜๋ฐ•"์„ ๋ฆฌํ„ดํ•˜๊ณ  3์ด๋ผ๋ฉด "์ˆ˜๋ฐ•์ˆ˜"๋ฅผ ๋ฆฌํ„ดํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

์ œํ•œ ์กฐ๊ฑด
n์€ ๊ธธ์ด 10,000์ดํ•˜์ธ ์ž์—ฐ์ˆ˜์ž…๋‹ˆ๋‹ค.
*/
const solution = (n) => {
  let answer = '';

  // '์ˆ˜๋ฐ•' ๋ฌธ์ž์—ด์„ ์ธ์ž ๊ฐ’์ธ n๋ฒˆ ๋งŒํผ ๋ฐ˜๋ณต.
  // ๊ทธ ๋‹ค์Œ 0๋ฒˆ์งธ๋ถ€ํ„ฐ n๋ฒˆ์งธ๊นŒ์ง€ ์ž˜๋ผ์„œ ์“ฐ๋ฉด ๋.
  answer = '์ˆ˜๋ฐ•'.repeat(n).slice(0, n);

  return answer;
};

console.log(solution(3));
console.log(solution(10));

repeat ๋ฉ”์„œ๋“œ๋ฅผ ๋ชฐ๋ผ์„œ ํ™€์ˆ˜ ์ž๋ฆฌ, ์ง์ˆ˜ ์ž๋ฆฌ ๋ฌธ์ž์—ด ๋Œ€์ฒดํ•˜๋ ค๊ณ  ๋ณ„์ง“ ๋‹คํ•˜๋‹ค๊ฐ€ ๊ตฌ๊ธ€๋ง์œผ๋กœ repeat ๋ฉ”์„œ๋“œ ์ฐพ์•„์„œ ํ•ด๊ฒฐ..

๋ณต์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค!