Store the generated permutations into the resultant arraylist
let Res = [ ] ; for ( let val of prevResult ) { for ( let i = 0 ; i <= val . length ; i ++ ) { Res . push ( val . substring ( 0 , i ) + ch + val . substring ( i ) ) ; } }