this method concatenates two strings and returns a new string. Have you ever heard about it whether a string can concatenate with another? It’s been really exciting method you should know about it.
const str1 = ‘Aktaruzzaman’;
const str2 = ‘Joti’;
console.log(str1.concat(‘ ‘, str2));
output: “Aktaruzzaman Joti”
const str = ‘I want to be a world-class web developer’;
const paragraph = ‘I am Aktaruzzaman Joti’;
const searchTerm= ‘Joti’;
Another fun method it is. It is reffered to removes whitespace from both sides of a string. Example below:
const greeting = ‘ Aktaruzzaman Joti ‘;
output: “Hello world!”;
You can separate a string by using this method mentioning it’s limit. Now let’s see how it works.
const str = ‘I love my country.’;
const words = str.split(‘ ‘);
This method has two parameters. One is to start a portion of a string and another parameter executes the length of this string.
const str = ‘Bangladesh’;
This method replaces a string with your given string. It’s a simple way to execute.
const p = ‘I love my country’;
output: ‘I like my country’
To check whether a string starts with a word you referred to, returning true or false.
const str1 = ‘Programming Hero’;
In this method, you can be checked whether a string may be found within another string. It returns true or false. Let’s look at the code:
const str1 = ‘ I am a student of Programming Hero’;
You can search a string whether it exists in another string or not. It also returns true or false value. Look at a glance:
const str1 = ‘Cats are the best!’;
How do you feel right now? I sure, you might gain confidence better than before. So, keep practicing and keep your footwork in developer’s world! All the best for you!