소스 보기

정답입니다.
틀렸습니다.
     //선택자
    const quizType = document.querySelector(".quiz_type");                  //퀴즈 종류
    const quizNumber = document.querySelector(".quiz_question .number");    //퀴즈 번호
    const quizAsk = document.querySelector(".quiz_question .ask");          //퀴즈 질문
    const quizConfirm = document.querySelector(".quiz_answer .confirm");    //정답 확인 버튼
    const quizResult = document.querySelector(".quiz_answer .result ");     //정답 결과
    const quizView = document.querySelector(".quiz_view");                  //강아지
    const quizSelects = document.querySelector(".quiz_selects");            //객관식 보기
    const quizChoice = quizSelects.querySelectorAll(".choice")                 //객관식 보기
    const quizSelect = quizSelects.querySelectorAll(".select")                 //객관식 보기
                    
    //문제정보
    const quizInfo = [
        {
            answerType : "웹 디자인 기능사",
            answerNum : "1. ",
            answerAsk : "컴퓨터 그래픽스 시스템의 입력 장치로 옳지 않은 것은?",
            answerChoice : [ "빔 프로젝터" , "키보드", "마우스", "스캐너"],
            answerResult : "1" ,
            answerEx : "빔 프로젝터는 상영하는 장치이다."
        }
    ]
                    
                    
    function updateQuiz(){
    //문제출력
    quizType.textContent = quizInfo[0].answerType;
    quizNumber.textContent = quizInfo[0].answerNum;
    quizAsk.textContent = quizInfo[0].answerAsk;
    quizResult.textContent = quizInfo[0].answerEx;
    
    //보기출력
    // for(let i = 0; i<4; i++){
    //     quizChoice[i].textContent = quizInfo[0].answerChoice[i];
    // }
                    
    quizInfo[0].answerChoice.forEach( (e,i) => {
        quizChoice[i].textContent = quizInfo[0].answerChoice[i];
    });
                    
    //해설 숨기기
    quizResult.style.display = "none"
                    
    //정답확인
    function answerQuiz(){
        //사용자 선택한 정답 == 문제 정답
        //사용자가 클릭한 input --> checked
                    
        for(let i =0; i<quizSelect.length; i++){
            if(quizSelect[i].checked == true){  //보기에 체크가 된 상태
                //체크된 번호 == 문제 번호
                if(quizSelect[i].value == quizInfo[0].answerResult){
                    // alert("정답")
                    quizView.classList.add("like");
                }else{
                    // alert("오답")
                    quizView.classList.add("dislike");
                    quizResult.style.display = "block";
                    quizConfirm.style.display = "none"
                }
            }
        }
    }
                    
    //정답클릭
    quizConfirm.addEventListener("click",answerQuiz)
    
                    
    }
    updateQuiz();
   <div class="quiz_wrap">
    <div class="quiz">
        <span class="quiz_type"></span>
        <h2 class="quiz_question">
            <span class="number"></span>
            <div class="ask"></div>
        </h2>
        <div class="quiz_view">
            <div class="dog">
                <div class="head">
                    <div class="ears"></div>
                    <div class="face"></div>
                    <div class="eyes">
                        <div class="teardrop"></div>
                    </div>
                    <div class="nose"></div>
                    <div class="mouth">
                        <div class="tongue"></div>
                    </div>
                    <div class="chin"></div>
                </div>
                <div class="body">
                    <div class="tail"></div>
                    <div class="legs"></div>
                </div>
            </div>
        </div>
        <div class="quiz_answer">
            <button class="confirm">정답 확인하기</button>
            <div class="result"></div>
        </div>
    </div> 
.quiz_wrap {
        display: flex;
        align-items: flex-start;
        justify-content: center;
        margin-top: 50px;
        margin-bottom: 150px;
        flex-wrap: wrap;
    }

    .quiz {
        max-width: 500px;
        width: 100%;
        background-color: #fff;
        border: 8px ridge #cacaca;
        margin: 10px;
    }

    .quiz_type {
        background-color: #cacaca;
        text-align: center;
        display: block;
        /*span이라 inline이어서*/
        font-size: 16px;
        border: 3px ridge #cacaca;
        color: #3b3b3b;
        font-family: "DungGeunMo";
        padding: 4px;
    }

    .quiz_question {
        border-top: 6px ridge #cacaca;
        border-bottom: 6px ridge #cacaca;
        padding: 20px;
        font-family: "TwayAir";
        line-height: 1.3;
    }

    .quiz_question .number {
        color: #b771f8;
    }

    .quiz_question .ask {
        display: inline;
    }

    .quiz_answer {
        border-top: 6px ridge #cacaca;
        padding: 10px;
        background-color: #f5f5f5;
    }

    .quiz_answer .confirm {
        border: 6px ridge #cacaca;
        width: 100%;
        font-size: 22px;
        padding: 13px 20px;
        background-color: #d6d6d6;
        font-family: "TwayAir";
        cursor: pointer;
    }

    .quiz_answer .result {
        width: 100%;
        font-size: 22px;
        padding: 13px 20px;
        border: 6px ridge #cacaca;
        box-sizing: border-box;
        text-align: center;
        font-family: "TwayAir";
        line-height: 1.3;
    }
    .quiz_answer .input {
        width: 100%;
        border: 6px ridge #cacaca;
        font-size: 22px;
        padding: 13px 20px;
        background-color: #fff;
        font-family: "TwayAir";
        margin-bottom: 10px;
    }
    .quiz_view {
        background-color: #f5f5f5;
        font-family: "TwayAir";
        position: relative;
        overflow: hidden;
    }
    .quiz_view .true {
        width: 120px;
        height: 120px;
        line-height: 120px;
        background-color: #8beeff;
        color: rgb(60, 68, 136);
        border-radius: 50%;
        text-align: center;
        position: absolute;
        left: 70%;
        top: 100px;
        opacity: 0;
    }
    .quiz_view .false {
        width: 120px;
        height: 120px;
        background-color: rgb(255, 205, 68);
        color: rgb(82, 39, 22);
        line-height: 120px;
        border-radius: 50%;
        text-align: center;
        position: absolute;
        right: 70%;
        top: 100px;
        opacity: 0;
    }
    .quiz_view.like .true{
        opacity: 1;
        animation: wobble 0.6s;
    }
    .quiz_view.dislike .false{
        opacity: 1;
        animation: wobble 0.6s; /*wobble 좌우로 흔드는 애니메이션*/
    }

    .quiz_selects {
        margin: 5px 0;
    }

    .quiz_selects label {
        display: flex;
    }
    .quiz_selects label input {
        position: absolute;
        left: -9999px;
    }
    .quiz_selects label span {
        font-size: 20px;
        line-height: 1.3 ;
        font-family: "TwayAir";
        padding: 10px;
        display: flex;
        align-items: center;
        width: 100%;
        border-radius: 5px;
        cursor: pointer;
    }

    .quiz_selects label span::before {
        content: '';
        width: 30px;
        height: 30px;
        border-radius: 50%;
        background: #fff;
        display: flex;
        margin-right: 15px;
        flex-shrink: 0;
        box-shadow: inset 0px 0px 0px 4px #b781e9;
        transition: all 0.25s;
    }

    .quiz_selects label input:checked + span {
        background-color: rgb(228, 224, 235);
    }

    .quiz_selects label input:checked + span::before {
        box-shadow: inset 0px 0px 0px 10px #b781e9;
    }

    .quiz_confirm {
        width: 100%;
        text-align: center;
    }
    .quiz_confirm .check {
        font-size: 22px;
        line-height: 1.3;
        padding: 13px 60px;
        border: 6px ridge #cacaca;
        box-sizing: border-box;
        text-align: center; 
        font-family: "TwayAir";
        cursor: pointer;
        margin: 40px 0;
        transition: background 0.3s;
    }

    .quiz_confirm .check:hover {
        background: #b080fd;
    }

    .quiz_confirm .ex {
        font-family: "DungGeunMo";
        font-size: 28px;
        font-weight: 500;

    }