Navigate back to the homepage

how to remove the last character from a string in react native?

Infinitbility
React Native
June 18th, 2022 · 1 min read

Hi Friends 👋,

Welcome To Infinitbility! ❤️

To remove the last character from a string in react native, use the slice(0, -1) method it will remove the last character of your string.

The slice() method returns a shallow copy of a portion of a string into a new string selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified.

1"Infinitbilityy".slice(0, -1) // Infinitbility

Today, I’m going to show How do I remove the last character from a string in react native, here I will use the javascript built-in method slice() to delete the last char from the string.

Let’s start today’s tutorial How do you remove the last character from a string in react native?

Example in React Native

In the following example, we are going to do

  1. Take example string
  2. apply slice(0, -1) method to string
  3. Print output in react native app screen
1import React, { Component } from 'react';
2import { Text } from 'react-native';
3
4class TextComponent extends Component {
5 render() {
6 return (
7 <Text>{"Infinitbilityy".slice(0, -1)}</Text>
8 );
9 }
10}
11
12export default TextComponent;

In the above program, we call subtract() and format() to get a previous month of the current date or custom date.

let’s check the output.

React Native, Example of remove last char from string
React Native, Example of remove last char from string

I hope it’s help you, All the best 👍.

Follow me on Twitter

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide

Tutorials

Categories

More articles from Infinitbility

how to get number of days between two dates in moment js?

Example of get number of days between two dates using moment js with step by step guide.

June 17th, 2022 · 1 min read

how to get previous month in moment js?

Example of get previous month using moment js with step by step guide.

June 17th, 2022 · 1 min read
© 2020–2022 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]