From f17457ee60fd7a03c6d18816ec8c9276d80fcaeb Mon Sep 17 00:00:00 2001 From: Wang HoEun Date: Tue, 7 Nov 2023 21:55:31 +0900 Subject: [PATCH 1/4] =?UTF-8?q?style:=20=EC=B4=88=EA=B8=B0=20=EC=84=B8?= =?UTF-8?q?=ED=8C=85=20=EB=B0=8F=20=ED=98=B8=EC=9D=80=EC=9D=B4=EC=9D=98=20?= =?UTF-8?q?=EA=B3=84=EC=82=B0=EA=B8=B0=EB=A1=9C=20header=20text=20?= =?UTF-8?q?=EB=B3=80=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- package.json | 2 +- yarn.lock | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 9ae7802..042afee 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@
-

혜인이의 계산기

+

호은이의 계산기

diff --git a/package.json b/package.json index 37a264c..8eb6760 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,6 @@ }, "devDependencies": { "typescript": "^5.0.2", - "vite": "^4.4.5" + "vite": "^4.5.0" } } diff --git a/yarn.lock b/yarn.lock index d92d861..44bf209 100644 --- a/yarn.lock +++ b/yarn.lock @@ -181,7 +181,7 @@ typescript@^5.0.2: resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78" integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w== -vite@^4.4.5: +vite@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/vite/-/vite-4.5.0.tgz#ec406295b4167ac3bc23e26f9c8ff559287cff26" integrity sha512-ulr8rNLA6rkyFAlVWw2q5YJ91v098AFQ2R0PRFwPzREXOUJQPtFUG0t+/ZikhaOCDqFoDhN6/v8Sq0o4araFAw== From 117f4f6e4c5788ba149b278e38fd5b44006436e0 Mon Sep 17 00:00:00 2001 From: Wang HoEun Date: Tue, 7 Nov 2023 22:07:33 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=EA=B3=84=EC=82=B0=EA=B8=B0=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20html=EC=97=90=20=EB=A7=9E=EA=B2=8C=20?= =?UTF-8?q?=EA=B8=B0=EB=B3=B8=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.ts | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/main.ts b/src/main.ts index 4fe51c7..4f10165 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1 +1,44 @@ import "./style.css"; + +const $ = (selector: string) => document.querySelector(selector); + +const num1Input = $('input[type="number"]:nth-of-type(1)') as HTMLInputElement; +const num2Input = $('input[type="number"]:nth-of-type(2)') as HTMLInputElement; +const selectOperator = $('select[name="calculate"]') as HTMLSelectElement; +const resultDisplay = $("h3") as HTMLHeadingElement; +const calculateButton = $("button"); + +function calculateResult() { + const num1 = parseFloat(num1Input.value); + const num2 = parseFloat(num2Input.value); + const operator = selectOperator.value; + + let result: number; + + switch (operator) { + case "sum": + result = num1 + num2; + break; + case "sub": + result = num1 - num2; + break; + case "mul": + result = num1 * num2; + break; + case "divide": + result = num1 / num2; + break; + default: + result = NaN; + } + + if (isNaN(result)) { + resultDisplay.textContent = "계산 불가"; + } else { + resultDisplay.textContent = result.toString(); + } +} + +if (calculateButton) { + calculateButton.addEventListener("click", calculateResult); +} From b10cc7593e96d330277fa574134823784c5abec4 Mon Sep 17 00:00:00 2001 From: Wang HoEun Date: Tue, 7 Nov 2023 22:20:16 +0900 Subject: [PATCH 3/4] =?UTF-8?q?style:=20css=20html=20=EC=86=8D=20=EC=84=A0?= =?UTF-8?q?=EC=96=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index 042afee..7271468 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,7 @@ + 타입스크립트로 계산기 만들기 From d78183e4c4d59cd53f7988515a9737566912d96a Mon Sep 17 00:00:00 2001 From: Wang HoEun Date: Wed, 8 Nov 2023 00:15:59 +0900 Subject: [PATCH 4/4] =?UTF-8?q?style:=20style=20import=20=EC=84=A0?= =?UTF-8?q?=EC=96=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index 4f10165..18d2eab 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,3 @@ -import "./style.css"; - const $ = (selector: string) => document.querySelector(selector); const num1Input = $('input[type="number"]:nth-of-type(1)') as HTMLInputElement;