String - A string is a sequence of characters in single quotes ('), double quotes ("), or backticks (`).
javascriptWelcome to JavaScript`;
const firstName = "Siyamala";
const lastName = 'Manikandan';
const message =
console.log(firstName);
console.log(lastName);
console.log(message);
`
OutPut
plaintext
Siyamala
Manikandan
Welcome to JavaScript
1.Length
returns the total number of characters in a string.
javascript
const language = "JavaScript";
console.log(language.length);
OutPut
plaintext
10
2.Uppercase
convert all characters to uppercase.
javascript
const text = "javascript";
console.log(text.toUpperCase());
Out
JAVASCRIPT
`markdown
**3.Lowercase
convert all characters to lowercase.
`plaintext
const text = "JAVASCRIPT";
console.log(text.toLowerCase());
`
OutPut
`markdown
javascript
`
4.Access Characters
Use the index position to access individual characters.
`plaintext
const word = "Coding";
console.log(word[0]);
console.log(word[3]);
`
OutPut
`markdown
C
i
`
5.indexOf()
returns the Character Position
`plaintext
const text = "JavaScript";
console.log(text.indexOf("S"));
`
OutPut
`markdown
4
`
6.includes()
used to check whether a specific value exists in an array
`plaintext
const course = "JavaScript Basics";
console.log(course.includes("Script"));
`
OutPut
`markdown
true
`
7.replace()
replaces the first matching value.
`plaintext
const sentence = "I love Java";
const result = sentence.replace("Java", "JavaScript");
console.log(result);
`
OutPut
`markdown
I love JavaScript
`
8.slice()
extracts a portion of a string.
`plaintext
const text = "JavaScript";
console.log(text.slice(0, 4));
`
OutPut
`markdown
Java
`
9.split()
Convert a string into an array.
`plaintext
const fruits = "Apple,Banana,Mango";
console.log(fruits.split(","));
`
OutPut
`markdown
["Apple", "Banana", "Mango"]
`
10.trim()
remove whitespace from both ends.
`plaintext
const username = " Sherin ";
console.log(username.trim());
`
OutPut
`markdown
Sherin
`
11.repeat()
repeats a string a specified number of times.
`plaintext
console.log("Hi ".repeat(3));
`
OutPut
`
Hi Hi Hi
`
Top comments (1)
Heyho!
I pressed a like on this article, because I hope you'll do 2 favors for me with regards to this very article:
Have you ever considered that dev.to has a ton of dev related articles,
but - not so surprisingly since devs have zero idea about how testing works and cannot even write good unit tests - testing related articles are scarce.
Aka you might consider gunning for the 'testing' niche with your next articles, as it is a more fertile ground than JS Beginner articles.
TL;DR I think you can provide more value with the same effort of work put in it, by chaning the subject towards testing, and automated testing.
Most important thing though:
I like the profile pic, but it'd be cooler if you could change the background into flames.
Oh... and also... years ago when I worked with QA contractors... they told me stories about the singing pillars of Hampi, James Bond Island, their culture's architectural and graphical obsession with wheels, and one of the more senior guys gave me a 1 hour laughter and joke filled presentation about how jainism might help my microfauna in my tummy so I can do the dailys in a less grumpy manner. I adhered to some advices, unfortunately I cannot go on a meat-free diet, because my ancestors developed a cuisine which is basically 99% meat. Everything in my country contains either meat or fat. I think even lollipops have traces of dried meat in them. It is like Eating Meat: The Country.
What I'm trying to say is that... I don't know your local of origin, but weaving in your culture might make the otherwise dry technical write ups more funnier and memorable on a human level.