I initiated a numerical array inside a javascript and to converted it into a string using join() but when I try to get a substr(), it doesn't to work. There seems to be a techincal error. Please help!
var array = [85, 13, 7, 42, 78, 9];
$("#div1").html("<b>This is the original array:</b><br><br>" + array.join("<br>"));
$("#div2").html("<br><b>This is the converted string:</b><br><br>" + array.join(""));
$("#div3").html("<br><b>The substring (from 0 to 3) is:</b><br><br>" + array.substr(0,3));
NOTE: div1,div2,div3 are 3 seperate divs with ids respectively. Thats where i want to display the results.
Aucun commentaire:
Enregistrer un commentaire