Skip to content

홍수진과제제출 #5

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions 1_solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let name = "신석";

// ? 부분에 예측 값을 작성해주세요(코드 실행 금지)

alert(`hello ${1}`); // ?
alert(`hello ${"name"}`); // ?
alert("hello ${name}"); // ?
alert(`hello ${name}`); // ?
alert(`hello ${1}`); // hello 1
alert(`hello ${"name"}`); // hello name
alert("hello ${name}"); // hello ${name}
alert(`hello ${name}`); // hello 신석
2 changes: 1 addition & 1 deletion 2_solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let user = {
years: 21,
};

// 여기에 코드를 작성해주세요
const {name: Name, years: age, isAdmin=false} = user;

alert(Name); // "민서"
alert(age); // 21
Expand Down
8 changes: 8 additions & 0 deletions 3_solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@ let user = {
part: "FE",
};

const json = JSON.stringify(user);
const parsed = JSON.parse(json);

console.log(typeof json);
console.log(json);

console.log(typeof parsed);
console.log(parsed);
//답 작성
5 changes: 4 additions & 1 deletion 4_solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ class Person {
getPerson() {
console.log(`이름: ${this.name}, 취미: ${this.hobby}`);
}
}
}

const sujin = new Person("수진","유튜브보기");
sujin.getPerson();
6 changes: 5 additions & 1 deletion 5_solution.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//5번 문제

const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];


const filtered = numbers.filter(numbers => numbers%2==0);
console.log(filtered)
40 changes: 27 additions & 13 deletions 6_solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,33 @@ let arr = [
{ part: "be", name: "기현", age: 25 }
];

// 1. staff 제거
arr = arr.filter(member => member.part !== "staff");


//arr.splice(2,2);

// 2. "fe"는 남기되 "보연"은 제거
arr = arr.filter(member => !(member.part === "fe" && member.name === "보연"));


// console.log(arr);

const filtered = arr.filter(arr1=> arr1.part !== "staff" );

const filtered2 = filtered.filter(arr1=>arr1.name !=="보연");




// 3. 나이 내림차순 정렬
arr.sort((a, b) => b.age - a.age);
filtered2.sort((a,b)=>b.age-a.age);

const newArray = filtered2.map(function(person){
return person.name;
});

console.log("최종 이름 배열: ")
console.log(newArray);

// 4. 이름만 뽑아 배열 만들기
const names = arr.map(member => member.name);
console.log("최종 이름 배열:", names);

// 5. 이름 한 줄씩 출력
names.forEach(name => console.log(name));

newArray.forEach(function(name){
console.log(name);
});



7 changes: 2 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
</head>
<body>
<h1>콘솔 확인용!</h1>
<script src="1_solution.js"></script>
<script src="2_solution.js"></script>
<script src="3_solution.js"></script>
<script src="4_solution.js"></script>
<script src="5_solution.js"></script>

<script src="6_solution.js"></script>

</body>
</html>