๊ฐ๋ฐ์ 99% ์ปค๋ฎค๋ํฐ์์ ์๋ค ๋จ์ด์!
TIL (Today I Learned) ๋ ์ง
2023. 01. 24
์ค๋ ์ฝ์ ๋ฒ์
๐ ์ํผ์๋ 35 ~ ์ํผ์๋ 38
์ฑ ์์ ๊ธฐ์ตํ๊ณ ์ถ์ ๋ด์ฉ์ ์จ๋ณด์ธ์.
๋น๋ฐ๋ฒํธ
ํด์ํจ์ - ๋ ์ธ๋ณด์ฐ ํ ์ด๋ธ
์ํธ
ํ๋ก๊ทธ๋๋ฐ ํจ๋ฌ๋ค์(๊ด์ )
์ ์ฐจ ์งํฅ ํ๋ก๊ทธ๋๋ฐ
๊ฐ์ฒด ์งํฅ ํ๋ก๊ทธ๋๋ฐ - ํด๋์ค, ์์
ํจ์ํ ํ๋ก๊ทธ๋๋ฐ - ์ ์ธํ ํ๋ก๊ทธ๋๋ฐ, ๋ช ๋ นํ ํ๋ก๊ทธ๋๋ฐ
์ค๋ ์ฝ์ ์๊ฐ์? ๋ ์ค๋ฅด๋ ์๊ฐ์ ๊ฐ๋ณ๊ฒ ์ ์ด๋ณด์ธ์
//ํ๋ ์ด์ด ๊ณต์ฅ, ํด๋์ค
class Player {
constructor(name, health, skill) {
this.name = name;
this.health = health;
this.skill = skill;
this.xp = 0;
}
}
//์์
class Human {
constructor(name) {
this.name = name;
this.arms = 2;
this.legs = 2;
}
}
class Baby extends Human {
constructor(name) {
this.cute = true;
}
cry() {
return `waa waa`;
}
}
//์ ์ธํ ํ๋ก๊ทธ๋๋ฐ
function spaceToHeart(text) {
return text.replaceAll(" ", "โก");
}
//๋ช
๋ นํ ํ๋ก๊ทธ๋๋ฐ
function spaceToHeart(text) {
let result = "";
for (let i = 0; i < text.length; i++) {
if (text[i] === " ") {
result += "โก";
} else {
result += text[i];
}
}
return result;
}
//ํจ์ํ ํ๋ก๊ทธ๋๋ฐ, ํ์ ์ ๊ฑฐ
function checkForOdd(item) {
return item % 2 === 0;
}
function removeOdd(items) {
return items.filter(checkForOdd);
}
๊ถ๊ธํ ๋ด์ฉ์ด ์๊ฑฐ๋, ์ ์ดํด๋์ง ์๋ ๋ด์ฉ์ด ์๋ค๋ฉด ์ ์ด๋ณด์ธ์.
//