Reputation:
I want function like parseInt() or parseFloat(), but it will output letter. In better option it will output only first letter. Like this:
var text = Hello World!
var newval = parseLetter(text);
Output: H
Upvotes: 1
Views: 156
Reputation: 924
Use this:
function parseLetter(letter){
return letter.charAt(0);
}
It will return the first letter of your string
Upvotes: 0
Reputation: 316
You want to get the first letter of your string as your output. Isn't it? If That is the case, try the following..,
var text = "Hello World!"
var newval = text.charAt(0);
Upvotes: 2