Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2b57d45
feat: practice1 1단계(계산기) 완료
winshine0326 Jul 28, 2024
bd9cec3
feat: practice1 2단계(함수로 분리하기) 완료
winshine0326 Jul 28, 2024
2b8362d
feat: practice1 3단계(객체 사용해보기) 완료
winshine0326 Jul 28, 2024
f815d4d
feat: practice1 4단계(화살표 함수 익히기) 완료
winshine0326 Jul 28, 2024
d83a2a0
feat: practice2 미션 완료
winshine0326 Jul 28, 2024
9f3d622
feat: todolist container HTML 및 CSS 작업
winshine0326 Jul 28, 2024
1fe12f1
chore: ul 태그 추가
winshine0326 Jul 28, 2024
de5ffb5
chore: form 태그 삭제
winshine0326 Jul 28, 2024
ea18948
style: ul style 추가
winshine0326 Jul 28, 2024
8cd8954
feat: 할 일 추가 기능 구현
winshine0326 Jul 28, 2024
548a47c
style: li button style 변경
winshine0326 Jul 28, 2024
0e7f092
feat: 텍스트 없이 +버튼을 누를 경우 경고창 띄우기
winshine0326 Jul 28, 2024
978513a
style: li style 변경
winshine0326 Jul 28, 2024
26cde3b
chore: favicon + 제목 수정
winshine0326 Jul 28, 2024
5a2635e
style: body background color 변경
winshine0326 Jul 28, 2024
2348d58
feat: 목록 클릭 시 줄긋기 + 더블클릭 시 목록에서 삭제
winshine0326 Jul 28, 2024
2203816
feat: 버튼 누를 시 밑줄, 한번 더 누르면 밑줄 사라짐+할일 텍스트 클릭 시 목록에서 제거
winshine0326 Jul 28, 2024
b180efd
style: 할 일 체크 시 텍스트 색깔 변경
winshine0326 Jul 28, 2024
42667b8
feat: 텍스트 더블클릭 시 삭제 -> 내용 수정으로 변경
winshine0326 Jul 28, 2024
16fd758
feat: 삭제버튼 추가
winshine0326 Jul 28, 2024
15d6f25
fix: 내용 없이 수정완료를 누르면 텍스트가 날라가는 문제 해결
winshine0326 Jul 28, 2024
c7828b9
refactor : lang en => ko 변경
winshine0326 Aug 3, 2024
22d619e
refactor : if else 구문 삼항연산자로 변경
winshine0326 Aug 3, 2024
d361f97
refactor : 쿼리셀렉터 -> getElementById 로 변경
winshine0326 Aug 3, 2024
88c58cf
refactor : 네이밍 컨벤션 케밥 표키법으로 표현
winshine0326 Aug 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion practice/practice1.js
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
// Mission 1
let num = {
a: 0,
sign: 0,
b: 0
}

const input = () => {
num.a = prompt("첫번째 값 입력")
num.sign = prompt("계산 부호")
num.b = prompt("두번쨰 값 입력")

num.a = parseInt(num.a)
num.b = parseInt(num.b)
}

const calc = (a, b, sign) => {
if (sign == '+')
alert(a + sign + b + '=' + (a + b))
else if (sign == '-')
alert(a + sign + b + '=' + (a - b))
else if (sign == '*')
alert(a + sign + b + '=' + (a * b))
else if (sign == '/')
alert(a + sign + b + '=' + (a / b))
else if (sign == '%')
alert(a + sign + b + '=' + (a % b))
}

input()
calc(num.a, num.b, num.sign)
19 changes: 19 additions & 0 deletions practice/practice2.js
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
// Mission 2
// 두 사람의 나이를 입력 받고 비교해주는 코드
let person1
let person2
let result

function input(){
person1 = prompt('첫번째 사람의 나이')
person2 = prompt('두번째 사람의 나이')
}

input()

result = person1===person2 ? '같다' : ((person1>person2) ? '첫번째가 더 크다' : '두번째가 더 크다' ) //삼항 연산자, Strict Equal 연산자
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주석 남기며 공부하는 방법 너무 좋은 것 같습니다!!

// 두 명의 나이가 같다면 result에 같다, 한 쪽이 크면 큰 쪽을 result에 저장.

if(!(!!person1) || !(!!person2)) // Double Exclamation Marks 연산자
alert('나이가 입력되야 합니다!') // 만약 person1 혹은 person2에 null값이 입력되면 느낌표 두개 연산자로 false로 변환하여 명확히 걸러줌.
else
alert(result)
23 changes: 23 additions & 0 deletions todolist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="ko">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ToDoList</title>
<link rel="stylesheet" href="style.css">
<link rel="icon" href="https://cdn-icons-png.flaticon.com/512/4345/4345037.png">
</head>

<body>
<div id="TodoContainer">
<h2>TodoList</h2>
<input type="text" placeholder="해야할 일 추가하기" id="text-container">
<button class="submit-button" onclick="addTodolist()">+</button>
<ul id="todolist">
</ul>
</div>
<script type="text/javascript" src="script.js"></script>
</body>

</html>
44 changes: 44 additions & 0 deletions todolist/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function addTodolist() {
let swt = true
let li = document.createElement('li')
let text = document.createElement('span')
let btn = document.createElement('button')
let delbtn = document.createElement('button')

delbtn.className = 'delbtn'
delbtn.innerHTML = "삭제"

li.appendChild(btn)
li.appendChild(text)
li.appendChild(delbtn)

const todo = document.getElementById('text-container')
if (!todo.value)
alert("해야할 일을 작성해주세요!")
else {
text.innerHTML = todo.value //li안에 들어갈 span 태그 안에 텍스트박스 value 값 넣어주기
const todolist = document.getElementById('todolist')
todolist.appendChild(li) // ul에 li 연결
todo.value = '' // 텍스트 박스 비우기
}
console.log(todolist)

btn.addEventListener('click', () => {
li.style.textDecoration = swt?"line-through":"none"
li.style.color = swt?"#a1a1a1":"black"
btn.style.backgroundColor = swt?"#e37e8e":"white"
swt = !swt
}) // 버튼 한번 클릭 시 텍스트에 줄 긋기

text.addEventListener('dblclick', () => {
let newtext = prompt("변경할 내용을 입력해주세요")
if(!(!!newtext))
alert("잘못된 요청입니다!") // 내용이 비워져있으면 수정x
else
text.innerHTML = newtext
}) // 텍스트 더블클릭 시 내용 수정

delbtn.addEventListener('click', () => {
todolist.removeChild(li)
}) // 딜리트 버튼 누를 시 리스트 삭제
}
74 changes: 74 additions & 0 deletions todolist/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
body{
background-color: #ffe4e9;
}

#TodoContainer{
background-color: #ffc0cb;
width:20rem;
margin:0 auto;
height: auto;
text-align: center;
padding: 2em 0;
border-radius: 3px;
}

#text-container{
width:70%;
height: 2.1em;
font-weight: 700;
border:none;
border-radius: 3px;
padding-left: 7px;
}
input:focus{
outline:none;
}

h2{
margin:0;
margin-bottom: 5%;
}

.submit-button{
height: 2rem;
width: 2rem;
background-color: #f78d9f;
border: none;
border-radius: 3px;
}

.submit-button:hover{
background-color: #ad606d;
}

ul{
margin: 20px auto;
list-style-type: none;
padding:0 10px;
width:85%;
text-align: left;
}

li{
margin: 8px 0;
font-weight: 500;
}

li>button{
background-color: #ffffff;
width: 1rem;
height: 1rem;
border: none;
border-radius: 2px;
margin-right: 5px;
}
li>button:hover{
background-color: #a6a6a6;
}

.delbtn{
float:right;
background-color: rgb(255, 112, 112);
height: auto;
width: auto;
}