https://www.acmicpc.net/problem/2675
my attempt
function stringRepeat(str) {
const ref = str.split(" ");
const repeat = Number(ref[0]); //3
const strin = ref[1]; //ABC
const strArr = strin.split("");
if (strin === "") {
console.log("nothing");
} else {
const result = strArr.map((v) => v.repeat(repeat)).join("");
console.log(result);
}
}
stringRepeat("5 /HTP"); // AAABBBCCC
Solution
Comments
Post a Comment