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

122
Views
Getting a red squiglly line under the first cards[0], I dont know what is causing it

this is minimal js, everything else is commented. I cannot understand why "cards[i]"(first one in the for loop) has a red squiggly line under it, I cannot run any console commands. Please help!

    let cards=document.querySelectorAll(".blocks");
    let pic,card,rand;
    let finals = [];
    const count = 10; 
    const max = 9;
    
    for(let k = 0; k < 1000; k++){
      rand = Math.round(Math.random() * max);
    //   !finals.includes(rand) && finals.push(rand)
      if(!finals.includes(rand))
      finals.push(rand);
    }
    finals = finals.slice(0, count)
    setupCards(finals);
    
    function setupCards(arr){
        
        for(let i=0;i<=arr.length;i++){
    ====>cards[i].style.backgroundImage=`url(images/${arr[i]}.jpg)`;
        // cards[i].style.transform="rotateY(180deg)";
        // cards[i].style.backgroundImage="url(images/back6.jpg)";             
     }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In this condition test:

for(let i=0;i<=arr.length;i++){

you are letting the i go from zero (which is the index of the first element) to the length of the array (which gets you to the last plus 1 element - which doesn't exist).

Try:

  for(let i=0;i<arr.length;i++){
about 4 years ago · Juan Pablo Isaza Report
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!