got results both dividing substrings , replacing multiple substrings using map array. split string n-length before substrings replaced 
eg: aabbccddee
maparray : {   aa: a,   ab: b, <<<<   bb: f,   cc: c,   dd: d,   ee: e }   
 result : afcde
i need string split length 2, code won't replace 'ab', instead of replacing 'aa' , 'bb' seperately. 
 can explain more if needed! in advance!
the code split string parts of 2 character length comes here, applies map , outputs resulting string.
var maparray = {    aa: 'a',    ab: 'b',    bb: 'f',    cc: 'c',    dd: 'd',    ee: 'e'  };    var inp = "aabbccddeex";  var out = inp.match(/.{1,2}/g).map(a => maparray[a] || "-").join('');    console.log(out);  
Comments
Post a Comment