-
Notifications
You must be signed in to change notification settings - Fork 0
4회차 과제 - 김정운 #9
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
base: main
Are you sure you want to change the base?
4회차 과제 - 김정운 #9
Conversation
이벤트 추가 및 historylist 추가
| const span = document.createElement("span"); | ||
| span.innerText = item; |
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.
span을 따로 만들었기 때문에 나중에 스타일 확장을 쉽게 할 수 있다는 것이 좋은 것 같습니다!
| // .calc-btn 이벤트 리스너 등록 ✅ | ||
| document.querySelectorAll(".calc-btn").forEach((btn) => { | ||
| btn.addEventListener("click", calculate); | ||
| }); |
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.
전반적으로 코드가 간결해서 읽기 쉬워 좋은 것 같습니다!
Limtaehyeon
left a comment
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 deleteButton = document.createElement("button"); | ||
| deleteButton.innerText = "삭제"; | ||
|
|
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.
참고 영상을 보면 지우는 버튼이 "X" 로 되어있기 때문에 삭제 대신에 "X" 로 해주는 것이 좋을 것 같습니다!!
| const li = document.createElement("li"); | ||
| const span = document.createElement("span"); | ||
| span.innerText = item; | ||
|
|
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.
변수명을 알아보기 싶게 li, span, item 으로 작성해서 자세히 이해할 수 있는 부분이 좋았습니다!
신경써서 구현한 부분
1. 계산 함수 구현
value에 클릭된 버튼의 텍스트 값을 가져온다.=을 누르면eval()로 계산하고.toFixed(2)로 소수점 둘째 자리까지 반올림 후 문자열로 변환2. 이벤트 리스너 구현
.num-bt,.calc-btn클래스를 가진 모든 버튼에click이벤트를 등록calculate()함수를 호출하여 계산 함수를 실행3. 기록 업데이트 함수 구현
<li>요소로 만들어 출력