Editing the contents of an Array of Strings in JavaScript -
i have doubts regarding how change contents of array (of strings) in javascript. if have array this:
var name = ["a","b","c","d","e","f","g","h","i","j","k"];
and want convert array this:
var name = ["a","d","e","f","g","h","i","j","k"];
that is, have remove of elements. know starting , ending indices of elements removed, in above example removed strings between "a" , "d"(i given indices of "a" , "d"). how can so?
note:here function in modified array. here, when pass function, s=1, e=3.
function replace(s,e) { var k= new array(); k=name.splice(s,e-s); cpyarr(k,name,k.length); }
cpyarr(arr1,arr2,n) function created copy arr1 arr2 (n elements)
i getting error in k=name.splice(s,s-e)
line
var name = ["a","b","c","d","e","f","g","h","i","j","k"]; function removesomeelems(arr,indices){ return arr.filter(function(char,index) { return indices.indexof(index) == -1 }); } console.log(removesomeelems(name,[1,2,4]));
Comments
Post a Comment