Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
inserting variable instead of a string when setting attributes in jquery
let currentNumber = 0;
let list = [ {
    question: "1. 325 children attended a concert at a school auditorium. 4/5 of the boys and 3/4 of the girls left the auditorium at the end of the concert. 29 more boys than girls remained in the auditorium. How many girls attended the concert?",
    answer: 80,
    youtube_id: "https://www.youtube.com/embed/voH_c33go2I"
},
{
    question: "2.  At first, Ben ad some red, blue and green marbles. During a game, he removed 54 red marbles. During a game, he removed 54 red marbles, gave away 40% of the blue marbles and increased the green marbles by 25%. After the game, the ratio of the number of red marbles to the number of blue marbles to the number of green marbles was 3:1:5. The total number of marbles he had before and after the game was the same.  How many green marbles had he increased during the game?",
    answer: 162,
    youtube_id: "https://youtu.be/embed/bLkp0BSVqWw"
},
{
    question: "What is 3 + 2",
    answer: 5,
    youtube_id: "https://www.youtube.com/embed/voH_c33go2I"
}

]

function submit() {
        let user_answer = parseInt($('#question-number').val())
        console.log(user_answer)
        console.log(list[currentNumber].answer)
        if (user_answer === list[currentNumber].answer) {
            isCorrect();
        } else {
            isWrong();
        }
    
}


function isWrong() {
    $(".wrong-sentence").css("visibility", "visible")
    $(".video").attr("src", list[currentNumber].youtube_id)
    $(".video").css("display", "block")
}


I want to make a quiz website but I am stuck inside my isWrong() function, I want to set the src attribute of the video tag but I am not sure how to do it with a variable or object props in my list array

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda