How to remove line breaks from start and end of a string in JavaScript

1 Answer

0 votes
let str = '\njavascript c c++ php\n';

str = str.trim();

console.log(str);

  
  
  
  
/*
run:
  
"javascript c c++ php"
  
*/

 



answered Apr 27, 2022 by avibootz
...