How to get the Nth character in a string with TypeScript

1 Answer

0 votes
const str = 'typescript c++ c php';

console.log(str.charAt(0)); 
console.log(str.charAt(1)); 

console.log(str.charAt(str.length - 1)); 
console.log(str.charAt(str.length - 2)); 
  
  
  
  
/*
run:

"t" 
"y" 
"p"
"h"
  
*/

 



answered May 15, 2022 by avibootz

Related questions

1 answer 155 views
1 answer 99 views
1 answer 150 views
1 answer 132 views
2 answers 128 views
...