Theory
A string is a sequence of characters. Strings are commonly used to represent names, messages, sentences and other textual information. String problems are very common in DSA and often involve searching, reversing, comparing or modifying characters.
Example
const text = "CodingWithMee";
console.log(text.length);
console.log(text[0]);
console.log(text.toUpperCase());
Expected Output
The length, first character and uppercase version of the string are displayed.
Practice
Write a program that reverses a string.
Interview Questions
- What is a string?
- How do you find the length of a string?
- How can a string be reversed?
- Why are strings important in DSA?