indices = (c, s) => s .split('') .reduce((a, e, i) => e === c ? a.concat(i) : a, []); indices('?', 'a?g??'); // [1, 3, 4]