How to get the Nth character in a string with Node.js

1 Answer

0 votes
const str = 'nodejs 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:

n
o
p
h
  
*/

 



answered May 15, 2022 by avibootz
...