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

...