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 281 views
2 answers 259 views
1 answer 192 views
1 answer 207 views
...