Get Last Character From String in React Native using charAt()

Hello friends, In today’s tutorial we would learn about something special in react native. There are so much functionality a developer requires at the time time of creating a mobile application. So recently when I was reading some article on stackoverflow then I found that few of our fellow developers have problem finding the last character of String text in react native. Because It’s bit tricky. So I thought let’s make a tutorial on it, Maybe it will help the others. So in this tutorial we would learn about Get Last Character From String in React Native using charAt() String method.

Content in this project Get Last Character From String in React Native using charAt() :-

1. Open your project’s main App.js file and import StyleSheet, SafeAreaView, Text and Button component.

2. Creating our main App component.

3. Creating a String named as temp with some random text.

4. Creating a function named as get_Last_Character(). In this function we would simply first get the length of the String using string length method. Then We would use the charAt() method of String and get the last character using -1 and print the last char into Console window.

5. Creating a Text and Button component.

6. Creating Style.

7. Complete Source Code for App.js File :-

Screenshot :-

Get Last Character From String in React Native using charAt()

Leave a Reply

Your email address will not be published. Required fields are marked *