let indices = []; let array = "scissors".split(''); let element = 's'; let idx = array.indexOf(element); while (idx !== -1) { indices.push(idx+1); idx = array.indexOf(element, idx + 1); } console.log(indices);