-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ 다현 ] #6
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굿굿 넘 수고했어! 어려웠을텐데 완죠니 굳굳!
|
||
const select = document.querySelector("select") as HTMLSelectElement; | ||
let showresult = document.querySelector("h3") as HTMLHeadingElement; | ||
const showResultButton = document.querySelector(".result"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요기에는 HTMLButtonElement
를 넣을 수 있겠다!
let showresult = document.querySelector("h3") as HTMLHeadingElement; | ||
const showResultButton = document.querySelector(".result"); | ||
|
||
showResultButton?.addEventListener("click", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요거 as 넣으면 해결되지 않나요?? 아닌가!!!??
const showResultButton = document.querySelector(".result"); | ||
|
||
showResultButton?.addEventListener("click", () => { | ||
const input1: number = parseFloat(firstInput.value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
함수가 기니까 그냥 안에 화살표 함수를 두는 것보다,함수를 새로 명명하는 게 좋을 것 같아요!
기능을 최대한 덜어내는 게 최선!
case "mul": | ||
result = input1 * input2; | ||
break; | ||
case "divide": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
나누기에 input2가 0인 케이스도 있답니다!
return; | ||
} | ||
showresult.textContent = String(result); | ||
alert(`계산 결과는 ${result}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alert까지 좋아요!
🌮 무엇을:
무엇을 개발했는지 짧게 설명해주세요! (개발 완료된 부분까지 설명)
css은 딱히 안 건드렸고(시간 이슈..), 숫자를 입력하고 연산자를 선택하면 계산된 값이 alarm으로도 뜨고, 화면에도 반영되게 하였다.
🌮 어떻게:
select value에 따라 case를 나눠서 switch 로 계산을 할 수 있게 만들었다.
입력값은 초기에는 string으로 설정되어있어서 parseFloat을 통해서 숫자로 바꿔서 연산이 가능하게 하였다.
🌮 얼마나:
1시간...?
const firstInput = document.querySelector(".first-input") as HTMLInputElement;
이렇게 선택하는 부분에서 뒤에 as를 안 붙이는 데에서 에러가 많이 났다. 그리고 속성 참조를 할 때도 옵셔널 체이닝 연산자를 써야하고 (null일 수도 있어서) 하여튼 상당히 정확한 무언가 를 요구하는 언어인것 같다..
🌮 구현 사항:
Screen.Recording.2023-11-08.at.6.11.54.PM.mov