How to replace the first occurrence of character in string with JavaScript

1 Answer

0 votes
let str = 'javascript typescript node.js';

str = str.replace(/t/i, '*');

console.log(str); 

  
  
  
  
/*
run:
  
"javascrip* typescript node.js"
  
*/

 



answered Jun 13, 2022 by avibootz
...