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

Related questions

1 answer 135 views
1 answer 104 views
1 answer 147 views
2 answers 129 views
1 answer 97 views
2 answers 131 views
...