I have given string "asdlfjsahdkljahskl" and have given array [1,2,3,1,7,2,1,2].My final output should be a, sd, lfj, s, ahdklja, hs, kl.
I know how to split the string but I don't know how to compare the string and cut according to given array
HTML Code
<button onclick="myFunction()">click me</button>
<p id="demo"></p>
JavaScript
var width = [1,4,2,6,1,1,10,1];
function myFunction() {
var str = "abcdefghijklmnopqrstuvwxyz";
var res = str.split("");
for(var j=0; j.length;j++){
document.write(width[j]);
}
document.getElementById("demo").innerHTML = res;
}
Thank you for your help
j.lengthdoes not make any sense since it is a number.