const restoreString = function(s, indices) { let result = s.split(""); let i = 0; for(char of s) { result.splice(indices[i], 1, char); i++; } return result.join('') };