How to get the second to last character in string with Node.js

1 Answer

0 votes
const s = 'nodejs';

const secondToLast = s[s.length - 2];

console.log(secondToLast); 

  
  
  
  
/*
run:
  
j
  
*/

 



answered May 18, 2022 by avibootz

Related questions

2 answers 272 views
2 answers 254 views
1 answer 182 views
1 answer 197 views
...