Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the last character of a string by coffeescript?

I have a string as below:

str = "abcdefg123"

I want to get the last character(3), how to make it by coffeescript?

I am a newcomer to coffeescript, hope someone can help me, thanks in advance!

like image 486
pangpang Avatar asked Nov 28 '25 00:11

pangpang


1 Answers

Enjoy some Coffeescript destructuring assignement and splats:

str = "abcdefg123"
[..., lastChar] = str
alert lastChar
like image 161
Shanoor Avatar answered Nov 30 '25 16:11

Shanoor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!