function findAllOccurrences(arr, target) { /* 1.使用indexOf找到arr中的索引 2.把索引存到newArr中 */ var newArr = [] arr.forEach((item, index) => { if(item == target){ newArr.push(index) } }) return newArr }
function findAllOccurrences(arr, target) { /* 1.使用indexOf找到arr中的索引 2.把索引存到newArr中 */ var newArr = [] arr.forEach((item, index) => { if(item == target){ newArr.push(index) } }) return newArr }