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 technical 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. That's where I want to display the results.
substron the array and not on the result ofarray.join. Thejoinfunction does not modify the array, it returns astringarray.joinin avar resultand then perform avar.substr(), it should work?array.join("").substr(0,3)