• monica_b1998OP
      link
      fedilink
      arrow-up
      9
      ·
      edit-2
      7 days ago

      I think it’s drawing some lines twice, but I didn’t think it’s worth adding more lines to prevent it. Suggestions, anyone? Edit: I updated line 18 to let j = i + 1;

  • bleistift2@sopuli.xyz
    link
    fedilink
    English
    arrow-up
    3
    ·
    6 days ago

    If you’re iterating over a whole array and need the index, like in ll.15f., you can instead write

    particles.forEach((particle, i) => {
      // loop body
    })
    

    There may be a performance hit (I haven’t tested it) because you’re invoking a function on each iteration. And it’s mostly a stylistic choice.