Monday, 24 April 2017

How should I get last character from String in NodeJS

I'm not able to get last character form a string using NodeJS,anyone should help me.
I'm trying this:-

var str  = 'abc';
var ret = str.charAt(2);
console.log(ret);


but I'm getting error something that charAt is not a function, and the heck is what, that, I'm trying this same in html it's worked fine, but I don't know what happened to NodeJS.

Anyone please tell me how should I get character from a specific index?



via Ansari Abdullah

No comments:

Post a Comment