From 6053ba74a3b044adc6fe99a03734f874e90b7193 Mon Sep 17 00:00:00 2001 From: leedasom050115 Date: Mon, 7 Apr 2025 17:11:01 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=B4=EB=8B=A4=EC=86=9C=EA=B3=BC=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1_solution.js | 8 ++++---- 2_solution.js | 6 +----- 3_solution.js | 6 ++++++ 4_solution.js | 6 +++++- 5_solution.js | 5 ++++- 6_solution.js | 25 +++++++++++-------------- 6 files changed, 31 insertions(+), 25 deletions(-) diff --git a/1_solution.js b/1_solution.js index 2d1ddc3..30f4771 100644 --- a/1_solution.js +++ b/1_solution.js @@ -4,7 +4,7 @@ let name = "신석"; // ? 부분에 예측 값을 작성해주세요(코드 실행 금지) -alert(`hello ${1}`); // ? -alert(`hello ${"name"}`); // ? -alert("hello ${name}"); // ? -alert(`hello ${name}`); // ? \ No newline at end of file +alert(`hello ${1}`); // hello 1 +alert(`hello ${"name"}`); // hello name +alert("hello ${name}"); // hello ${name} +alert(`hello ${name}`); // hello 신석 \ No newline at end of file diff --git a/2_solution.js b/2_solution.js index e5b5e37..0eadca5 100644 --- a/2_solution.js +++ b/2_solution.js @@ -5,8 +5,4 @@ let user = { years: 21, }; -// 여기에 코드를 작성해주세요 - -alert(Name); // "민서" -alert(age); // 21 -alert(isAdmin); // false \ No newline at end of file +const {name: Name, years: age, isAdmin = false } = user; \ No newline at end of file diff --git a/3_solution.js b/3_solution.js index 60fba3a..cdbb34b 100644 --- a/3_solution.js +++ b/3_solution.js @@ -5,4 +5,10 @@ let user = { part: "FE", }; + const json = JSON.stringify(user); + + const parsed = JSON.parse(json); + console.log(parsed); + + //답 작성 \ No newline at end of file diff --git a/4_solution.js b/4_solution.js index dd39a09..ea7d879 100644 --- a/4_solution.js +++ b/4_solution.js @@ -9,4 +9,8 @@ class Person { getPerson() { console.log(`이름: ${this.name}, 취미: ${this.hobby}`); } -} \ No newline at end of file +} + +const lion=new Person("다솜","게임"); +lion.getPerson(); + diff --git a/5_solution.js b/5_solution.js index 91cb066..201930a 100644 --- a/5_solution.js +++ b/5_solution.js @@ -1,3 +1,6 @@ //5번 문제 -const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; \ No newline at end of file +const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + +const filtered = numbers.filter(number => number % 2 === 0); +console.log(filtered); \ No newline at end of file diff --git a/6_solution.js b/6_solution.js index af7922b..1c219d7 100644 --- a/6_solution.js +++ b/6_solution.js @@ -6,19 +6,16 @@ let arr = [ { part: "be", name: "기현", age: 25 } ]; - // 1. staff 제거 - arr = arr.filter(member => member.part !== "staff"); + const filtered = arr.filter(lion => lion.part === "fe" && "be"); + console.log(filtered); - // 2. "fe"는 남기되 "보연"은 제거 - arr = arr.filter(member => !(member.part === "fe" && member.name === "보연")); + + + filtered.splice (2,2); + console.log(filtered); + + +let names = filtered.map(member => member.name); + +name.forEach(name => console.log(name)) - // 3. 나이 내림차순 정렬 - arr.sort((a, b) => b.age - a.age); - - // 4. 이름만 뽑아 배열 만들기 - const names = arr.map(member => member.name); - console.log("최종 이름 배열:", names); - - // 5. 이름 한 줄씩 출력 - names.forEach(name => console.log(name)); - \ No newline at end of file