-
Notifications
You must be signed in to change notification settings - Fork 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
[Project1/조민철] Colors #6
base: JSmini_datalater
Are you sure you want to change the base?
Changes from 4 commits
13d7dd1
346be0f
d8ff78d
03b312e
3a0b1b7
fa66e54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es2021: true, | ||
}, | ||
extends: [ | ||
'airbnb-base', | ||
], | ||
parserOptions: { | ||
ecmaVersion: 12, | ||
sourceType: 'module', | ||
}, | ||
rules: { | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
.vscode |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Ramdon Color</title> | ||
<link rel="stylesheet" href="style.css" /> | ||
</head> | ||
<body> | ||
<button id="button">Click Me!</button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 혹시 button에 class가 아닌 id 값을 넣으신 특별한 이유가 있을까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이번 프로젝트에서는 버튼이 하나인 게 명확해서 id 속성을 선택했습니다. 하지만 말씀하신 대로 재사용성을 고려하면 class 속성을 사용하는 게 더 적합하다는 것에 저도 동의합니다! 다음에도 같은 상황이 오면 class를 사용하는 게 확장 가능성 측면에서 더 낫다는 생각이 드네요ㅎㅎ 수정해서 반영하겠습니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
<script src="./main.js"></script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const $button = document.getElementById('button'); | ||
|
||
const $body = document.querySelector('body'); | ||
|
||
const randomColorValue = () => Math.floor(Math.random() * 256); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제가 알기로는, Math.random()은 0이상 1미만의 난수를 생성하는것으로 알고있습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아, 이게 최대값이 255여서 난수 0~1미만으로 곱셈한 결과가 최소값 0부터 최대 255까지 나오도록 256으로 했습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 앗...! 그렇네요ㅋㅋ 잠시 최대값이 256이라고 생각했습니다. |
||
|
||
const randomColor = () => `rgba(${randomColorValue()}, ${randomColorValue()}, ${randomColorValue()}`; | ||
|
||
$button.addEventListener('click', () => { | ||
$body.style.backgroundColor = randomColor(); | ||
}); |
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.
깨알같은 부분이지만.. title에 오타가 있군요!
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.
랜돈 컬러 ㅋㅋㅋ 매의 눈 감사합니다~~ 변경해서 반영하겠습니다
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.
3a0b1b7