javascript (20) ์ธ๋ค์ผํ ๋ฆฌ์คํธํ DAY 1 #0.2 ~ #1.2 ํ๋ก ํธ, ๋ฐฑ์๋ ์ค๋น๋ฅผ ์ํด ๋ฏธ๋ฆฌ 0.0~0.4๋ฅผ ๋ค์ด์ผํ๋ค... ์๋ค์๋ค๊ฐ ์ง๊ธ 1์๊ฐ์งธ ํํ์ณค๋ค... https://ssocoit.tistory.com/188 ์ฐธ๊ณ #0.2 server Setup https://www.npmjs.com/package/ws ๋จผ์ node, ws, express, pug ์ค์น ๋๋ ์ด๋ฏธ ๋ ธ๋๋ ์ค์น๋์ด ์์ผ๋ฏ๋ก ๋๋จธ์ง ์ธ๊ฐ๋ง ์ถ๊ฐ๋ก ์ค์นํจ.. npm i ws npm i express npm i pug github์ ์ฌ๋ฆฐ๋ค๋ฉด readme ํ์ผ๋ ์ถ๊ฐ๋ก ์์ฑํด์ค ์ ์๋ค. ํฐ๋ฏธ๋์ npm init-y ๋ฅผ ์ ๋ ฅํ๋ฉด ๋ญ๊ฐ ์์ด๋ณด์ด๋ ๊ธฐ๋ณธ package.json ํ์ผ์ ์์ ํด์ค๋ค. ๊ฑฐ๊ธฐ์ ์ถ๊ฐ๋ก ๋ง๋ถ์ด๊ณ ์ถ์ ๋ด์ฉ์ ์์ฑํ๋ฉด ๋๋ค. nodemon๊ณผ babel์ ์ฌ์ฉํ ๊ฒ์ด๋ ํฐ๋ฏธ๋.. DAY 14 #8.0 Geolocation ์ฐ์ ๋ ์จ๋ฅผ ์ป๊ธฐ ์ํด ๋ฏธ๋ฆฌ index.html์ ์ค๋น๋ฅผ ํด์ค๋ค. function onGeoOk(position){console.log(position);} function onGeoError(){alert("Can't find you. no Weather for you.");} navigator.geolocation.getCurrentPosition(onGeoOk, onGeoError); ์์ ์ฝ๋๋ก ๋ธ๋ผ์ฐ์ ์์๋ ๋ด ์์น๋ฅผ ๋ฐ์์จ๋ค. ๋ค๋ง getCurrentPosition()์๊ฒ๋ 2๊ฐ์ argument๊ฐ ํ์ํ๋ฐ, ํ๋๋ ๋ชจ๋ ๊ฒ ์ ์ฑ๊ณตํ์ ๋ ์คํ๋ ํจ์(onGeoOk), ๋ค๋ฅธ ํ๋๋ ์๋ฌ๊ฐ ๋ฐ์ํ์ ๋ ์คํ๋ ํจ์(onGeoError)์ด๋ค. ์ฑ๊ณตํ์ ์์๋ ํด๋น .. DAY 13 7.6 ~ 7.8 TO DO LIST #7.6 Deleting To Dos part One ์ ๋ฒ ์ฝ๋์์ ์ญ์ ๊ธฐ๋ฅ์ ์ ์คํ๋์ผ๋, ๋ฌธ์ ๋ ๊ฐ์ ์ด๋ฆ์ ํญ๋ชฉ์ด ์์ ๋๋ค. ๋ค์๊ณผ ๊ฐ์ด '๋๋ฃจํ ๋ณด๊ธฐ'๊ฐ ๋๊ฐ๊ฐ ์์ ๋, ๋๋ฃจํ ๋ณด๊ธฐ ๋ ์ค ํ๋๋ฅผ ์ญ์ ํ์ ๋ ์ด๋ค ๊ฒ์ ์ญ์ ํ๋์ง ๋ชจ๋ฅธ๋ค. ๋๋ฌธ์ array์ ๊ฐ item์ id๋ฅผ ๋ถ์ฌํด ๊ณ ์ ์ฑ์ ๊ฐ๊ฒํ ๊ฒ์ธ๋ฐ, ์ด ๊ณ ์ ์ฑ์ Date.now() ํจ์๋ก ๋ถ์ฌํ ๊ฒ์ด๋ค. Date.now()๋ ๋ฐ๋ฆฌ์ด(1000/1์ด)๋ฅผ ์ฃผ๋ ํจ์๋ก, ์ด๋ฅผ ๊ฐ item์๊ฒ ๊ณ ์ ํ ์์ด๋ ๊ฐ์ผ๋ก ๋ถ์ฌํ ๊ฒ์ด๋ค. handleToDoSubmit function handleToDoSubmit(event) { event.preventDefault(); const newTodo = toDo.. DAY 12 7.0 ~ 7.5 TO DO LIST (์์ด ๋ง์ DAY 12์๋ 7.0~7.5, DAY 13์๋ 7.6~7.8, DAY 14์๋ 8.0~8.2๋ก ๋๋๋ค.) #7.0 Setup index.html todo-form ๋ด์ input์๋ ํ ์ผ์ ์ ๋ ฅ๋ฐ๊ณ , ul ํ๊ทธ์๋ ์ ์ฅํ text๊ฐ ๋์ด๋ ์ ์๊ฒ ํ๋ค. todo.js const toDoForm = document.getElementById("todo-form"); const toDoInput = document.querySelector("#todo-form input"); // const toDoInput = toDoForm.querySelector("input"); // ์ด๋ฐ ์์ผ๋ก ์ธ ์๋ ์๋ค. const toDoList = document.g.. DAY 11 6.0 - 6.2 background.js // img ํ์ผ ๋ช ์ ๋ด์ ๋ณ์ const images = ["0.jpeg", "1.jpeg", "2.jpeg"]; // ์ด๋ฏธ์ง ๋๋ค ์ถ๋ ฅ const chosenImage = images[Math.floor(Math.random() * images.length)]; // document์ img ํ๊ทธ๋ฅผ ๋ง๋๋ ๋ณ์ ์์ฑ const bgImage = document.createElement("img"); // bgImage์ src์ ์ฃผ์๋ฅผ ๋๋ค์ผ๋ก ๋์ bgImage.src = `img/${chosenImage}`; // html์ img ํ๊ทธ๋ฅผ ์์ฑํ๋ค. document.body.appendChild(bgImage); img๋ฅผ ๋ฐฐ๊ฒฝ์ผ๋ก ํ๊ณ ์ถ๋ค๋ฉด body >.. DAY 10 5.0 ~ 5.3 ์ด๋ฒ ๊ธ์ ๊ฑฐ์ ๋ค ์ผ์ ๋์ฏค์ ๊ฐ์๊ธฐ ์ปดํจํฐ๊ฐ ๋ฉ์ถ๋๋ฐ๋์... ๊ฐ๋ตํ๊ฒ ์จ์ผ์ง ใ ...ํ index.html 00:00 app.js const clock = document.querySelector("h2#clock"); function getClock() { const date = new Date(); // date.getHours()๋ฑ ์๊ฐ ๊ฐ์ ์ซ์ ๊ฐ์ด๋ค. // padStart๋ string ๊ฐ์๋ง ์ฌ์ฉํ ์ ์์ผ๋ฏ๋ก, ๋ณํํด์ค์ผ ํ๋ค. const hours = String(date.getHours()).padStart(2, "0"); const minutes = String(date.getMinutes()).padStart(2, "0"); const seconds = Str.. DAY 8 #4.4 Getting Username submit ๋ฒํผ์ ํด๋ฆญํ์ ๋, form ์์ฒด๋ฅผ ์ฌ๋ผ์ง๊ฒ ํ๋ ๋ฐฉ๋ฒ์ด 2๊ฐ๊ฐ ์๋ค. โ form ํ๊ทธ ์์ฒด๋ฅผ ์ ๊ฑฐํ๋ ๊ฒ โก css์์ display:none; ์์ฑ์ ์ถ๊ฐํด์ฃผ๋ ๊ฒ ์๋๋ form์์ ์ ๋ ฅ๊ฐ์ ๋ฐ์์ค๋ฉด form์ ์ ๊ฑฐํ๊ณ , ๋ฐ์์จ ์ ๋ ฅ๊ฐ์ ์ถ๋ ฅํ๋ ์ฝ๋๋ค. index.html login-form์์ ์ ๋ ฅ๊ฐ์ ๋ฐ์์ค๋ฉด form ํ๊ทธ๋ ์์ ์ฌ๋ผ์ง ๊ฒ์ด๊ณ , h1 ํ๊ทธ๊ฐ ๋ณด์ฌ์ง๊ฒ ๋ ๊ฒ์ด๋ค. style.css ์๋ ๋ค์๊ณผ ๊ฐ์ ํด๋์ค๋ฅผ ๋ง๋ค์๋ค. .hidden{ display:none; } /* ์ข ๋น์ทํ ์์ฑ์๋ display:hidden;์ด ์์ง๋ง, ์ด๋ ๊ทธ๋ฅ ๋ณด์ด์ง ์๊ฒ ์จ๊ฒจ์ฃผ๋ ๊ฒ ๋ฟ ํด๋น ์์๊ฐ ์ฐจ์งํ๋ ๊ณต๊ฐ๋ ๊ทธ๋๋ก์ด๋ฉฐ ๋ฐ๋ผ์ html์์ .. DAY 5 #2.13 Conditionals prompt(); ์ฌ์ฉ์์๊ฒ ์ฐฝ์ ๋์ ๊ฐ์ ๋ฐ์์ค์ง๋ง, ๊ฐ์ ๋ฐ์์ฌ ๋ ๊น์ง ์ฝ๋์ ์คํ์ ๋ฉ์ถ๋ ์ค๋๋ ๋ฐฉ์์ผ๋ก css๋ฅผ ๋ฐ๊ฟ ์๋ ์๋ค. typeof ๋ผ๋ ํค์๋๋ variable์ type์ ๋ณผ์ ์๋ ํค์๋์ธ๋ฐ, prompt()์์๋ ์ซ์๋ฅผ ์ ๋ ฅ๋ฐ๊ณ ์ด๋ฅผ typeof๋ก ์ถ๋ ฅํด๋ string์ด๋ผ๊ณ ์ ๋ ฅ๋๋ค. prompt์ type์ string์ด default์ด๊ธฐ ๋๋ฌธ์ด๋ค. parseInt(); ์ซ์๋ก ๊ตฌ์ฑ๋ string type์ number type์ผ๋ก ๋ณํ์์ผ์ค๋ค. console.log(typeof "15", typeof parseInt("15")); // string number const age = parseInt(prompt("Please write y.. ์ด์ 1 2 3 ๋ค์