How to replace an element in an array with Node.js

1 Answer

0 votes
const arr = ['node.js', 'php', 'python', 'c', 'c#', 'java'];
  
const index = arr.indexOf('c#'); 

if (index !== -1) {
  	arr[index] = 'vb';
}
  
console.log(arr); 
  
  
  
  
/*
run:
  
[ 'node.js', 'php', 'python', 'c', 'vb', 'java' ]
  
*/

 



answered Jul 6, 2022 by avibootz
...