How to find and replace value in array with JavaScript

1 Answer

0 votes
const arr = [1, 3, 8, 9, 17, 18];

const index = arr.findIndex((e) => e === 8);
arr[index] = 100;

console.log(arr); 





/*
run:

[1, 3, 100, 9, 17, 18]

*/

 



answered Feb 14, 2021 by avibootz
...