JAVASCRIPT

자바스크립트 틀린문제 정리하기!

ture403 2023. 3. 3. 14:53

- Frederick Philips Brooks
Mythical Man-Month 저자
728x90
반응형

01. 다음의 출력값을 보고 빈칸을 채우시오!

{
    var x = 100; 
    var y = 200; 
    var z = "javascript"; 

    console.log(__);
    console.log(__);
    console.log(__);

    //100
    //200
    //300
}
결과확인하기
x
y
x+y

02. 다음의 출력값을 보고 빈칸을 채우시오!

{
    let x = 100;
    let y = 200;
    let z = "javascript";

    x = ___;   
    y = ___;
    z = ___;

    console.log(x);
    console.log(y);
    console.log(z);

    //300
    //400
    //jquery
}
결과확인하기
300
200
jquery

03. 다음의 출력값을 보고 빈칸을 채우시오!

{
    let x = 100;
    let y = 200;
    let z = "javascript";

    x ___ 300;       
    y ___ 400;       
    z ___ "jquery";  

    console.log(x);
    console.log(y);
    console.log(z);

    //400
    //-200
    //javascriptjquery
}
결과확인하기
+=
-=
+=

04. 다음의 출력값을 보고 빈칸을 채우시오!

{
    const arr = ________();   

    arr[0] = 100;               
    arr[1] = 200;               
    arr[2] = "javascript";     

    console.log(arr[0]);
    console.log(arr[1]);
    console.log(arr[2]);

    //100
    //200
    //javascript
}
결과확인하기
new Array

05. 다음의 출력값을 보고 빈칸을 채우시오!

{
    const arr = [___________________];    

    console.log(arr[0]);
    console.log(arr[1]);
    console.log(arr[2]);

    //100
    //200
    //javascript
}
결과확인하기
[100,200,"javascript]

06. 다음의 출력값을 보고 빈칸을 채우시오!

{
    const obj = new Object();

    obj[0] = 100;
    obj[1] = 200;
    obj[2] = "javascript";

    console.log(______);
    console.log(______);
    console.log(______);

    //100
    //200
    //javascript
}
결과확인하기
obj[0]
obj[1]
obj[2]

07. 다음의 출력값을 보고 빈칸을 채우시오!(console.log를 사용할 것)

{
    const obj = new Object();
    
    obj.a = 100;
    obj.b = 200;
    obj.c = "javascript";

    _____________________
    _____________________
    _____________________

    //100
    //200
    //javascript
}
결과확인하기
console.log(obj.a)
console.log(obj.b)
console.log(obj.c)

08. 다음의 출력값을 보고 빈칸을 채우시오!

{
    const obj = {____________________};

    console.log(obj.a);
    console.log(obj.b);
    console.log(obj.c);

    //100
    //200
    //javascript
}
결과확인하기
a:100, b:200, c:"javascropt"

09. 다음의 출력값을 보고 빈칸을 채우시오!

{
    const obj = [
        {a:100, b:200},
        {c:"javascript"}
    ];

    console.log(________);
    console.log(________);
    console.log(________);

    //100
    //200
    //javascript
}
결과확인하기
obj[0].a
obj[0].b
obj[1].c

10. 다음의 출력값을 보고 빈칸을 채우시오!

{
    const obj = {
        a: 100,
        b: [200, 300],
        c: "javascript"
    }
    console.log(________);
    console.log(________);
    console.log(________);

    //200
    //300
    //200300
}
결과확인하기
obj.b[0]
obj.b[1]
obj.b

11. 다음의 출력값을 보고 빈칸을 채우시오!

{
    const a = 100;
    const b = 200;
    const c = "javascript";

    const obj = { _________ }

    document.write(obj.a);
    document.write(obj.b);
    document.write(obj.c);

    //100
    //200
    //javascript
}
결과확인하기
a,b,c

12. 다음의 출력값을 보고 빈칸을 채우시오!

{
    const obj = {
        a: 100,
        b: [200, ____],
        c: "javascript",
        d: _________(){
            document.write("javascript가 실행되었습니다.");
        },
        e: function(){
            document.write( _______ + "가 실행되었습니다.");    //변수값 사용
        },
        f: function(){
            document.write( _______ + "가 실행되었습니다.");    //this를 사용
        }
    }

    document.write(obj.a);
    document.write(obj.b);
    document.write(obj.b[0]);
    document.write(obj.b[1]);
    document.write(obj.c);
    obj.d();
    obj.e();
    obj.f();

    //100
    //200,300
    //200
    //300
    //javascript
    //javascript가 실행되었습니다.
    //javascript가 실행되었습니다.
    //javascript가 실행되었습니다.
}
결과확인하기
300
function
c
this.c

13. 다음의 결괏값을 완성하시오.

{
    for( let i=1; i<10; i++){
        if(i % 2 == 0) {
            document.write(i);
        }
    }
}
결과확인하기
2,4,6,8

14. 다음의 결괏값을 완성하시오.

{
    for( let i=1; i<10; i++){
        if( true ) {
            document.write(i);
        }
    }
}
결과확인하기
1,2,3,4,5,6,7,8,9

15. 다음의 결괏값을 완성하시오.

{
    const func = function(){
        document.write("함수가 실행되었습니다.");
    }
    func();
}
결과확인하기
함수가 실행되었습니다.

16. 다음의 결괏값을 완성하시오.

{
    if( 1 ){
        document.write("조건문이 실행되었습니다.(true)");
    } else {
        document.write("조건문이 실행되었습니다.(false)");
    }
}
결과확인하기
조건문이 실행되었습니다.(true)

17. 다음의 결괏값을 완성하시오.

{
    let num = 10;

    if( num == 100 ){
        document.write("조건문이 실행되었습니다.(1)");
        if( num == 100 ){
            document.write("조건문이 실행되었습니다.(2)");
            if( num == 100){
                document.write("조건문이 실행되었습니다.(3)");
            }
        }
    } else {
        document.write("조건문이 실행되었습니다.(4)");
    }
}
결과확인하기
조건문이 실행되었습니다.(4)

18. 다음의 결괏값을 완성하시오.

{
    let num = 10;

    (num == 100) ? document.write("true") : document.write("false");
}
결과확인하기
false

19. 다음의 결괏값을 완성하시오.

{
    let num = 0;
    while( num <= 5 ){
        document.write( num + ". 반복문이 실행되었습니다.");  
        num++;
    }
}
결과확인하기
0. 반복문이 실행되었습니다.
1. 반복문이 실행되었습니다.
2. 반복문이 실행되었습니다.
3. 반복문이 실행되었습니다.
4. 반복문이 실행되었습니다.
5. 반복문이 실행되었습니다.

20. 다음의 결괏값을 완성하시오.

{
    const str = [100, 200, 300, 400, 500];

    str.forEach((element, index, array) =>l {
        document.write(element);
        document.write(index);
        document.write(array);
    });
}
결과확인하기
el: 100,200,300,400,500
index:0,1,2,3,4
array :[100, 200, 300, 400, 500] *5

틀린문제 복습하기

04. 다음의 출력값을 보고 빈칸을 채우시오

{
    const arr = ________();   

    arr[0] = 100;               
    arr[1] = 200;               
    arr[2] = "javascript";     

    console.log(arr[0]);
    console.log(arr[1]);
    console.log(arr[2]);

    //100
    //200
    //javascript
}

오답으로 New array로 적었음 

정답은 new Array() 입니다. 

배열을 표현 할수 있는 방식은 여러 가지 있습니다.

  • new Array를 써서 사용하는방법
  • new Array를 사용해서 한줄로 쓰는방법
  • new Array를 생략하고 인덱스 하나씩 지정해주는 방법
  • new Array를 생략하고 한줄로 하는 방법

20. 다음의 결괏값을 완성하시오.

{
    const str = [100, 200, 300, 400, 500];

    str.forEach((element, index, array) =>l {
        document.write(element);
        document.write(index);
        document.write(array);
    });
}

forEach문은 반복을 할떄 쓰입니다. for문과 다르게 element, index, array 를 갖고 있습니다. 

element 는 변수 안에 있는 값을 출력해 줍니다. 위 코드를 참조 하시면 100,200,300,400,500으로 출력됩니다.

index 값은 순번을 알려줍니다. 위 코드를 참조 하면 0,1,2,3,4로 출력됩니다.

array는 배열 전체를 출력 해줄떄 쓰입니다. 위 코드를 참조하시면 [100,200,300,400,500]으로 5번 출력 됩니다.