WeniVooks

검색

JavaScript 베이스캠프

기본 개념 확인 문제

1. 기본 개념 확인 문제

다음 문제들을 풀어보며 지금까지 배운 내용을 점검해보세요.

1.1 문제 1

다음 코드의 출력 결과는 무엇일까요?

let x = 5;
let y = '7';
console.log(x + y);
let x = 5;
let y = '7';
console.log(x + y);

a) 12
b) 57
c) "57"
d) 5 + "7"

1.2 문제 2

다음 코드에서 출력되는 값은 무엇일까요?

let a = 10;
let b = 3;
console.log(a % b);
let a = 10;
let b = 3;
console.log(a % b);

a) 3.33
b) 3
c) 1
d) 0.3

1.3 문제 3

다음 코드의 출력 결과는 무엇일까요?

let fruits = ['apple', 'banana', 'orange'];
console.log(fruits[1]);
let fruits = ['apple', 'banana', 'orange'];
console.log(fruits[1]);

a) apple
b) banana
c) orange
d) undefined

1.4 문제 4

다음 코드의 출력 결과는 무엇일까요?

function multiply(a, b) {
  return a * b;
}
console.log(multiply(3, 4));
function multiply(a, b) {
  return a * b;
}
console.log(multiply(3, 4));

a) 7
b) 12
c) "12"
d) "3 * 4"

1.5 문제 5

다음 코드의 출력 결과는 무엇일까요?

let numbers = [1, 2, 3, 4, 5];
let sum = 0;
 
for (let i = 0; i < numbers.length; i++) {
  if (numbers[i] % 2 === 0) {
    sum += numbers[i];
  }
}
 
console.log(sum);
let numbers = [1, 2, 3, 4, 5];
let sum = 0;
 
for (let i = 0; i < numbers.length; i++) {
  if (numbers[i] % 2 === 0) {
    sum += numbers[i];
  }
}
 
console.log(sum);

a) 15
b) 9
c) 6
d) 3

1.6 문제 6

다음 코드의 출력 결과는 무엇일까요?

let person = {
  name: 'John',
  age: 30,
  city: 'New York',
};
 
for (let key in person) {
  console.log(key + ': ' + person[key]);
}
let person = {
  name: 'John',
  age: 30,
  city: 'New York',
};
 
for (let key in person) {
  console.log(key + ': ' + person[key]);
}

a) John, 30, New York
b) name: John, age: 30, city: New York
c) name: John
age: 30
city: New York
d) ["name", "age", "city"]

1.7 문제 7

아래 데이터에서 회원들의 평균 나이를 구하는 코드를 작성해주세요.

[
  {
    _id: 'f6901678-35e2-41f7-Ba74-929bc7dadca5',
    index: '1',
    name: '복세정',
    email: 'user-8zvjl65@Pulvinar.com',
    phone: '010-4372-3348',
    country: '세인트빈센트 그레나딘',
    address: '양산로 11-4',
    job: '화학연구원',
    age: '49',
  },
  {
    _id: '27caf754-dd27-40ae-A746-e9bc87075596',
    index: '2',
    name: '설기태',
    email: 'user-kk0afa8@diam.net',
    phone: '010-3284-0552',
    country: '괌',
    address: '석촌호수로 70-1',
    job: '기자',
    age: '33',
  },
  {
    _id: '51ef1986-7401-4a72-Cf15-1340b361d1f8',
    index: '3',
    name: '만호윤',
    email: 'user-bjea5w0@Volutpat.io',
    phone: '010-2023-4818',
    country: '키르기스스탄',
    address: '공덕로 97-2',
    job: '경찰관',
    age: '31',
  },
  {
    _id: '0950e357-353d-489e-C294-141fde6b2cb7',
    index: '4',
    name: '오윤찬',
    email: 'user-za2s6li@dolor.net',
    phone: '010-2084-3157',
    country: '미국',
    address: '행운동 30-8',
    job: '기자',
    age: '24',
  },
  {
    _id: '4630538d-096f-44e7-B870-a2d569930163',
    index: '5',
    name: '고유주',
    email: 'user-htadlwv@Elementum.org',
    phone: '010-8412-9862',
    country: '시에라리온',
    address: '용두동 23-7',
    job: '아나운서',
    age: '41',
  },
];
[
  {
    _id: 'f6901678-35e2-41f7-Ba74-929bc7dadca5',
    index: '1',
    name: '복세정',
    email: 'user-8zvjl65@Pulvinar.com',
    phone: '010-4372-3348',
    country: '세인트빈센트 그레나딘',
    address: '양산로 11-4',
    job: '화학연구원',
    age: '49',
  },
  {
    _id: '27caf754-dd27-40ae-A746-e9bc87075596',
    index: '2',
    name: '설기태',
    email: 'user-kk0afa8@diam.net',
    phone: '010-3284-0552',
    country: '괌',
    address: '석촌호수로 70-1',
    job: '기자',
    age: '33',
  },
  {
    _id: '51ef1986-7401-4a72-Cf15-1340b361d1f8',
    index: '3',
    name: '만호윤',
    email: 'user-bjea5w0@Volutpat.io',
    phone: '010-2023-4818',
    country: '키르기스스탄',
    address: '공덕로 97-2',
    job: '경찰관',
    age: '31',
  },
  {
    _id: '0950e357-353d-489e-C294-141fde6b2cb7',
    index: '4',
    name: '오윤찬',
    email: 'user-za2s6li@dolor.net',
    phone: '010-2084-3157',
    country: '미국',
    address: '행운동 30-8',
    job: '기자',
    age: '24',
  },
  {
    _id: '4630538d-096f-44e7-B870-a2d569930163',
    index: '5',
    name: '고유주',
    email: 'user-htadlwv@Elementum.org',
    phone: '010-8412-9862',
    country: '시에라리온',
    address: '용두동 23-7',
    job: '아나운서',
    age: '41',
  },
];
7장 기본 개념을 확인해 봅시다8장 DOM