How to keep only first N characters in a string with Node.js

1 Answer

0 votes
let str = 'NodeJS C++ C PHP';

const N = 6;

str = str.substring(0, N);

console.log(str);

  
  
  
  
/*
run:

NodeJS
  
*/

 



answered May 15, 2022 by avibootz

Related questions

...