• Hi Eduardo,

q_p isn't always >=1.
if(aux[j]+aux[j+1] != "//")
(not equal to //) q_p will still be 0 - and total+=amount[i]/0 will result in infinity.

It's hard to advise without knowing exactly what the data look like and what you want to achieve. But for me your code looks a bit to complicated. Maybe this works for you:

`var q_p = 0;var aux = "";for(var i = 0; i < status.length;i++){       aux = String(projects[i]);       if(status[i] != "Not accepted" && aux.indexOf("//") > -1){           q_p += 1;      }q_p = q_p == 0 ? 1 : q_p;total += (amount[i]/q_p);}total`

Rainer

• Hi,

Thanks Rainer. In this case, the code you kindly gave doesn't do what I need, because I need to count how many times "//" appear in each string. In addition, each string has at least one repetition. That is why q_p is always >= 1.

• Just to clarify, when I tested it, q_p was indeed between 1 and 2 in that item. Nonetheless, Podio, while editing the field, says it's infinity. The 3 strings in Projects[] have this approximate form:

1) xxx xxx ///
2) xxx xxx ///
3) xxx xxx /// xxx xxx ///

• Hi Eduardo,
that's strange. The only reason  I can think of is that the 3 arrays (status, project,s amount) don't have the same length. Did you check that?
Btw: the number of // in projects[i] you can get with: String(projects[i]).split("//").length - 1 (if you use it var aux must be = 0 not = "").

`var q_p = 0;var aux = 0;for(var i = 0; i < status.length;i++){    if(status[i] != "Not accepted"){       aux = String(projects[i]).split("//").length - 1;       q_p += aux;      }q_p = q_p == 0 ? 1 : q_p;total += (amount[i]/q_p);};total`
• Hi Rainer,

Thanks.  Yes, they have the same length, as they come from the same items.  Thanks for the new line of code.

Cheers