Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!