How to get first N characters of a string in Node.js

1 Answer

0 votes
const s = "node.js";
  
const N = 4;
    
const firstN = s.slice(0, N)
    
console.log(firstN);
  
  
  
    
      
/*
run:
      
node
      
*/

 



answered Jul 11, 2022 by avibootz

Related questions

1 answer 101 views
1 answer 112 views
1 answer 137 views
2 answers 141 views
1 answer 107 views
1 answer 136 views
...