I started with a numeric array in JavaScript and converted it to a string using the join
method. However, when attempting to extract a substring using substr
, I encountered a technical issue. Can someone please assist me with this problem?
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));
PLEASE NOTE: The elements with IDs div1
, div2
, and div3
represent separate divs where I intend to display the respective results.