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

1 Answer

0 votes
const s = "node.js";
  
const N = 3;
  
const lastN = s.slice(s.length - N);
  
console.log(lastN);
  
  
  
    
      
/*
run:
      
.js
      
*/

 



answered Jul 11, 2022 by avibootz

Related questions

1 answer 106 views
2 answers 131 views
1 answer 111 views
1 answer 101 views
1 answer 113 views
1 answer 132 views
...