How to get the second to last character in string with TypeScript

1 Answer

0 votes
const s = 'typescript';

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

console.log(secondToLast); 

  
  
  
  
/*
run:
  
"p"
  
*/

 



answered May 18, 2022 by avibootz
...