Javascript for loop not appending list in dictionary -


and i'm not sure understand problem @ all.

var vtf=[]; // dictionary maps number-> list var length; var s; // list of numbers s.length = length // length , s set values  for(i=0; i<length; i++) {     var f=s[i];      if(f in vtf)        vtf[f].push(i);     else        vtf[f]=[i]; } 

so check if vtf contains value f=s[i]. if appends list contained @ vtf[f] , if doesn't makes new list element.

the problem after running every index of vtf contains first added despite me knowing every value saved in vtf should have list of multiple elements.

i can't understand i'm doing wrong. when put alerts inside if statement don't pop when put them outside loop, same value, show it's evaluating true number of times.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -