Navigate back to the homepage

how to add space in string in typescript?

Infinitbility
TypeScript
July 16th, 2022 · 1 min read
how to add space in string in typescript?

Add space beginning of the string in typescript

To add space beginning of the string in typescript, use blank space with the + operator it will concatenate the string and return a new string with space.

1let str: string = "infinitbility";
2
3// add blank space
4str = " " + str;
5console.log(str) // 👉️ " infinitbility"

To show space at the beginning of the string you should put a blank space string before the + operator, like in the above example.

Add space at the end of the string in typescript

To space at the end of the string in typescript, use the + operator with a blank space string it will concatenate the string and return a new string with space.

1let str: string = "infinitbility";
2
3// add blank space
4str = str + " ";
5console.log(str) // 👉️ "infinitbility "

To show space at the end of the string you should put a blank space string after the + operator, like in the above example.

Add space between string characters in typescript

To add space between string characters in typescript, use the split() with join() method with space separator it will add space for each character.

1let str: string = "infinitbility";
2
3// add blank space
4str = str.split('').join(' ');
5
6console.log(str) // 👉️ "i n f i n i t b i l i t y"

I hope it helps 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 add two numbers in react native?

how to add two numbers in react native?

An example of add two numbers in react native with a step-by-step example.

July 15th, 2022 · 1 min read
how to check webpack version in react js?

how to check webpack version in react js?

An example of check webpack version in react js with step by step guide.

July 15th, 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]