How to get first character of String in Javascript
Use s.charAt(0)
Example:
const s = "banana";
const firstChar = s.charAt(0); // == 'b'
// This will print 'b'
console.log(firstChar);
Use s.charAt(0)
const s = "banana";
const firstChar = s.charAt(0); // == 'b'
// This will print 'b'
console.log(firstChar);