const mystr = "hello"; const first = mystr.substr(0,1); const first = mystr.charAt(0);Or a function:
firstChar(s) { if (typeof(s) != 'string') return undefined; if (s.length == 0) return undefined; return s.charAt(0); }
const mystr = "hello"; const first = mystr.substr(0,1); const first = mystr.charAt(0);Or a function:
firstChar(s) { if (typeof(s) != 'string') return undefined; if (s.length == 0) return undefined; return s.charAt(0); }