javascript - How to get rid of the first undefined -


is there no easier way rid of first element of undefined this, checking in loops isn't first element?

    var text;      (d=0; d<json_nya_svar.length; d++){         (c=0; c<json_nya_svar[d].length; c++) {             if (c==0 && d==0) text=json_nya_svar[d][c] + ";";             else text += json_nya_svar[d][c] + ";";}     text += "\r\n";     } 

just give text initial value:

var text = ''; 

also, bear in mind loop variables global, can lead various problems in long run. don't forget add var before declaration:

var text = ''; var json_nya_svar = [[1, 2, 3], [4, 5, 6]];  (var d=0; d<json_nya_svar.length; d++){     (var c=0; c<json_nya_svar[d].length; c++) {         text += json_nya_svar[d][c] + ";";     }     text += "\r\n"; }  console.log(text); 

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -