From 6c365a22032d24969a19896eeccf500ff994e44b Mon Sep 17 00:00:00 2001 From: kub938 Date: Mon, 20 Oct 2025 23:52:04 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=EA=B5=AC=EB=B6=84=EC=9E=90=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/App.js b/src/App.js index 091aa0a5..a6c88dfd 100644 --- a/src/App.js +++ b/src/App.js @@ -1,5 +1,23 @@ +import { Console } from "@woowacourse/mission-utils"; + class App { - async run() {} + async run() { + const divChr = [",", "/", ":"]; + let numbers; + let input = await Console.readLineAsync(); + console.log(input); + + if (input.startsWith("//")) { + const parts = input.split(/\\n/); + const customDiv = parts[0].replace("//", ""); // ";" + for (let i = 0; i < customDiv.length; i++) { + divChr.push(customDiv[i]); + } + numbers = [parts[1]]; + } else { + numbers = [input]; + } + } } export default App; From c5feb6ac1ed0940c06dc0049d470681d8efaff82 Mon Sep 17 00:00:00 2001 From: kub938 Date: Mon, 20 Oct 2025 23:53:18 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=EA=B5=AC=EB=B6=84=EC=9E=90?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EC=88=AB=EC=9E=90=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC=20=EB=B0=8F=20=EC=B4=9D=ED=95=A9=20=EA=B3=84=EC=82=B0?= =?UTF-8?q?,=20=EC=9E=98=EB=AA=BB=EB=90=9C=20=EC=9E=85=EB=A0=A5=EC=97=90?= =?UTF-8?q?=20=EB=94=B0=EB=A5=B8=20=EC=97=90=EB=9F=AC=20=ED=95=B8=EB=93=A4?= =?UTF-8?q?=EB=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/App.js b/src/App.js index a6c88dfd..39da14b4 100644 --- a/src/App.js +++ b/src/App.js @@ -3,6 +3,7 @@ import { Console } from "@woowacourse/mission-utils"; class App { async run() { const divChr = [",", "/", ":"]; + let result = 0; let numbers; let input = await Console.readLineAsync(); console.log(input); @@ -17,6 +18,24 @@ class App { } else { numbers = [input]; } + + console.log(numbers); + divChr.forEach((chr) => { + numbers = numbers.flatMap((part) => part.split(chr)); + }); + + numbers.forEach((str) => { + const num = Number(str); + if (isNaN(num) || str.trim() === "") { + throw new Error("[ERROR] 잘못된 입력 입니다."); + } + if (num < 0) { + throw new Error("[ERROR] 음수는 입력할 수 없습니다."); + } + result += num; + }); + + Console.print(`결과 : ${result}`); } }