get the last letter of a string

you can use the .length and the index of a string to get its last value

Javascript

var my_string = "hello im a string";
var last_part_of_my_string = my_string[my_string.length - 1];
console.log(last_part_of_my_string); // this should return g in the console.

Other Items in javascript
Page Views

This page has been viewed 267 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹

Random Quote
therock Somewhere along this crazy road I learned (often times the hard way) the most important things I can do is be authentic, trust my gut, be the hardest worker in the room, celebrate the mistakes, be a grateful man and always remember that it's nice to be important, but it's more important to be nice.
The Rock