Conversation
added 6 commits
November 7, 2023 21:55
Open
hae2ni
reviewed
Nov 15, 2023
Member
hae2ni
left a comment
There was a problem hiding this comment.
호으니! 진짜 넘넘 잘해줬다!! 코드도 넘 깔끔쓰하고 고생했어요!
| <body> | ||
| <header> | ||
| <h1>혜인이의 계산기</h1> | ||
| <h1>호은이의 계산기</h1> |
| @@ -0,0 +1,42 @@ | |||
| const $ = (selector: string) => document.querySelector(selector); | |||
|
|
|||
| const num1Input = $('input[type="number"]:nth-of-type(1)') as HTMLInputElement; | |||
Member
There was a problem hiding this comment.
머야머야! 선택자 장인이자나!!! 진짜 장하다ㅠㅠ 넘넘 잘해
| @@ -0,0 +1,42 @@ | |||
| const $ = (selector: string) => document.querySelector(selector); | |||
|
|
||
| let result: number; | ||
|
|
||
| switch (operator) { |
| result = NaN; | ||
| } | ||
|
|
||
| if (isNaN(result)) { |
| } | ||
|
|
||
| if (calculateButton) { | ||
| calculateButton.addEventListener("click", calculateResult); |
SooY2
reviewed
Nov 18, 2023
| result = NaN; | ||
| } | ||
|
|
||
| if (isNaN(result)) { |
| } | ||
| } | ||
|
|
||
| if (calculateButton) { |
There was a problem hiding this comment.
if안에 calculateButton를 넣어준 이유가 몬가요..???? calculateButton가 참/거짓으로 판별되는지 궁금해요!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
계산기 프로젝트
🌮 무엇을:
🌮 어떻게:
const $ = (selector: string) => document.querySelector(selector);: $ 함수는 주어진 선택자에 해당하는 첫 번째 HTML 요소를 선택하는 함수이다. 선택자를 매개변수로 받고, document.querySelector를 사용하여 해당 요소를 선택했다.
const num1Input = $('input[type="number"]:nth-of-type(1)') as HTMLInputElement;: 첫 번째 숫자 입력 필드를 선택하고 해당 요소를 HTMLInputElement로 타입 캐스팅했다. $ 함수를 사용하여 선택자 'input[type="number"]:nth-of-type(1)'를 통해 첫 번째 숫자 입력 필드를 선택할 수 있도록 했다.
const num2Input = $('input[type="number"]:nth-of-type(2)') as HTMLInputElement;: 두 번째 숫자 입력 필드를 선택하고 해당 요소를 HTMLInputElement로 타입 캐스팅했다. $ 함수를 사용하여 선택자 'input[type="number"]:nth-of-type(2)'를 통해 두 번째 숫자 입력 필드를 선택할 수 있도록 했다.
const selectOperator = $('select[name="calculate"]') as HTMLSelectElement;: 연산자 선택 요소를 선택하고 해당 요소를 HTMLSelectElement로 타입 캐스팅했다. $ 함수를 사용하여 선택자 'select[name="calculate"]'를 통해 연산자 선택 요소를 선택할 수 있도록 했다.
const resultDisplay = $("h3") as HTMLHeadingElement;: 결과를 표시할 h3 요소를 선택하고 해당 요소를 HTMLHeadingElement로 타입 캐스팅했다. $ 함수를 사용하여 선택자 "h3"를 통해 h3 요소를 선택하도록 했다.
const calculateButton = $("button");: "결과는?" 버튼을 의미한다.
function calculateResult() { ... }: calculateResult 함수는 버튼 클릭 이벤트에 연결되는 함수로, 입력된 숫자와 선택된 연산자에 따라 계산을 수행하고 결과를 표시하는 역할을 한다. 결과는 resultDisplay에 표시된다.
if (calculateButton) { ... }: "결과는?" 버튼이 존재하면 버튼 클릭 이벤트에 calculateResult 함수를 연결한다. 그래서 결과 표시!
🌮 얼마나:
🌮 구현 사항:
bandicam.2023-11-08.00-22-53-611.mp4