Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda