Open
Conversation
dooohun
reviewed
Apr 8, 2025
Contributor
dooohun
left a comment
There was a problem hiding this comment.
수고하셨습니다!
코드도 깔끔한 편이고, 전체적으로 읽기 편했습니다👍
간단하게 코드 리뷰 남겼으니, 확인해보고 답변 남겨주세요~
| function WinningNumbers() { | ||
| const result_list = document.querySelector(".result"); | ||
| const resultNumbers = LottoNumber(); | ||
| const old_result_list = document.querySelector(".result .balls"); |
Comment on lines
+30
to
+31
| document.getElementById("buy_count").addEventListener("input", () => { | ||
| const count = document.getElementById("buy_count").value; |
Contributor
There was a problem hiding this comment.
Suggested change
| document.getElementById("buy_count").addEventListener("input", () => { | |
| const count = document.getElementById("buy_count").value; | |
| document.getElementById("buy_count").addEventListener("input", (e) => { | |
| const count = e.target.value; |
이런식으로 사용 가능해요! 여기서 e가 의미하게 무엇인지 학습해보세요!
Author
There was a problem hiding this comment.
e는 이벤트 객체로 이벤트가 발생했을 때 브라우저가 자동으로 만들어주는 객체입니다.
이벤트가 발생한 HTML 요소를 가르키는 데 위와 같은 상황에선 e.target.value = input창에 입력된 값입니다.
e에 대해 학습완료했습니닷!
| }); | ||
|
|
||
| document.getElementById("buy_btn").addEventListener("click", () => { | ||
| const countInput = document.getElementById("buy_count").value; |
Comment on lines
+71
to
+78
| <div class="balls"> | ||
| <div class="ball" id="yellow">${myNumbers[0]}</div> | ||
| <div class="ball" id="blue">${myNumbers[1]}</div> | ||
| <div class="ball" id="red">${myNumbers[2]}</div> | ||
| <div class="ball" id="gray">${myNumbers[3]}</div> | ||
| <div class="ball" id="green">${myNumbers[4]}</div> | ||
| <div class="ball" id="yellow">${myNumbers[5]}</div> | ||
| </div> |
Contributor
There was a problem hiding this comment.
위에서 result_list에서 작성한 내용하고 거의 비슷한 거 같아요. 아래쪽도 거의 비슷한 거 같은데, 어떻게 하면 줄일 수 있을까요? (재사용성을 고려해서 코드를 짜보면 좋을 거 같아요!)
Author
There was a problem hiding this comment.
function createBalls(numbers) {
const colorId = ["yellow", "blue", "red", "gray", "green", "yellow"];
let html = '
';
for (let i = 0; i < numbesr.length; i++) {
html +=
}
html += '
';for (let i = 0; i < numbesr.length; i++) {
html +=
<div class="ball" id="${colorId[i]}">${numbers[i]}</div>;}
html += '
return html;
}
재사용 함수를 만들면 될 것 같습니다!
my_result_list.innerHTML +=
${createBalls(myNumbers)};
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.
No description provided.