How to concatenate strings with a separator in Node.js

1 Answer

0 votes
const str1 = 'nodejs';
const str2 = 'c';
const str3 = 'c++';

const str = [str1, str2, str3].join('-');

console.log(str); 


  
  
  
  
/*
run:
  
nodejs-c-c++
  
*/

 



answered May 29, 2022 by avibootz

Related questions

1 answer 265 views
3 answers 336 views
2 answers 299 views
1 answer 231 views
1 answer 210 views
...