Relative Content

Tag Archive for javascriptloops

for loop in vanilla JavaScript

I have a rate number for 3 different products,
and i am trying to render a star svg base of number of rate.
for example product A has rate 3, I want to render star img, 3 times.
the maximum star they can have is 5.

How to can I stop this loop from crashing?

I’m working on a project and am writing an if statement inside of a for loop. Everything works fine with the shipPos for e.x when I try to console log them (console.log(shipPos[i]) but when I do an if statement and load the websites it just get stuck at loading forever.

Javascript : Looping through elements in a changing array

I have a webpage with a form that i want to reorganize.
All the fields are in one <table>, and to reorder it, i created other tables.
I want now to dispatch the fields of the first table given a certain condition.
My problem is, as i loop through my elements and moving them, the javascript array is changing, hence missing some items.