JavaScript String Exercise Last Updated : 07 Apr, 2025 Comments Improve Suggest changes Like Article Like Report JavaScript string is a primitive data type and is used for storing and manipulating a sequence of characters. It can contain zero or more characters within single or double quotes. This article contains a wide collection of JavaScript Programming examples based on String. JavaScript let s = "GeeksforGeeks" console.log(s); console.log(typeof s); OutputGeeksforGeeksstringEasy QuestionsThe Easy level includes articles that cover fundamental operations and straightforward tasks with JavaScript arrays.Length of JS String Reverse a string in JSRemove a character from a string in JS Delete the first character from JS String Remove Text from a String in JSIterate Over String Characters in JS Sort a string in JS Check if String Has Only Alphabets in JSCapitalize the First Letter in JS Convert Comma-Separated String to Array in JS Get Last Character in JS String String strip in JavaScript Replace Multiple Spaces with Single Space in JS Number to String Conversion in JS Add characters to a string in JS Count String Occurrences in JS Find Index of Character in JS JavaScript string formatting Byte Array to String Conversion in JS Count Each Character’s Occurrence in JS Insert String at Specific Index in JS Remove All Line Breaks from String in JS Get Last N Characters in JS Check String Equality in JS Substring check in JavaScript Count Words in String using JS String to array conversion in JavaScript Vowel Count in JS String Case-Insensitive Comparison in JS String to Boolean Conversion in JS Get First Word in JS String Get First and Last Character in JS Check for Whitespace in JS Character Array from String in JS Replace Multiple Characters in JS Replace Forward Slash Globally in JS String Modify Textarea Content in JS Alphabetically Sort String in JS Find Unique Characters in String using JS Strip Non-Numeric Characters in JS Count Each Letter in String in JS Sort Array of Strings in JS Check if String Starts With Another in JS Vowel or Consonant Check in JS Get First Three Characters of string in JS Slice vs Substring in JS Single vs Double Quotes in JS Check Repeated Characters in String using JSFloat to String Conversion in JS Keep First N Characters in String in JSSplit string into array of words in JS Check for Digit in String in JS Check character is vowel or not in JS Remove Last Character from string using JS Substr vs Substring in JS Compare Two Strings in JS Count Character Occurrence in JS Multiline String to Array Conversion in JS Compare Two Strings in JS Get Nth Occurrence of Character of String in JS Swap Characters in String using JS Find smallest and largest word in a string using JSConcatenate Strings in JS Char to String Conversion in JS Check if Character is Digit using JS Generate String of Specific Length in JS Add Prefix and Suffix to String in JS Access Characters in String using JS Convert String to Roman Numerals in JS Case-Insensitive Alphabetical Sort in JS Count Alphabets in String using JS First Occurrence of Substring in JS Check String Start Pattern in JSPad String to Specified Length using JS Reverse a string in place using JS Get string length Property in JS Count Alphabets in JS Float to String Conversion in JS Medium QuestionsThe Medium level includes articles that delve deeper into working with JavaScript strings, exploring more advanced operations and methodsHash a String in JS Extract number from a string in JS Validate JSON String in JS Convert Image to Base64 in JS String to Date Conversion in JS JS RegExp(Regular Expression) Remove Non-Alphanumeric Characters using JS Remove Non-ASCII Characters using JS Title Case Conversion in JS Convert Object to String in JS Create String with Multiple Spaces in JS Palindrome Check in JS Replace Multiple Strings in JS Remove Punctuation from String in JS Convert User Input to RegExp in JS Remove occurrences of character in a string using JS URLify String (Spaces to %20) using JS Count number of alphabets using JS Replace Dots in JS String Count Specific Character Occurrence in JS Use Quotes in String in JS Truncate String with Ellipsis in JS Extract Emails from String using JSExtract URLs from String in JS String to Binary Conversion in JS Character Order Pattern Check in JS Check if String is Pangram using JS Replace Words with RegEx in JS Most Frequent Word in String using JS Add Two Binary Strings in JS Find index of Last Occurrence of Substring using JS Capitalize First letter of Each Sentence in JS Permutation Check for Strings using JS Truncate string to a certain length using JS Toggle Character Case in String using JS Print Alphabetical Character Frequency using JS Remove consecutive duplicate characters using JS Recursive Palindrome Check in JS Anagram Check for Strings using JS Match Character with Options in JS Check Isomorphic Strings using JS Print all subsequences of a string using JS Find second most repeated word using JSMask Characters Except Last using JS Check if String is Made of Repeating Substring in JS Extract strings with a digit using JS Find kth non-repeating character using JS Find Strings Matching Pattern in Dictionary using JS Find Second Most Repeated Word in Sequence using JS Check Equal Character Frequency using JS Check if String Can Split into Four Distinct Parts using JSCount distinct subsequences using JS Count Equal Pairs in String using JS Add Multiple Binary Strings using JS Count Distinct Occurrences as Subsequence in JS Count Flips for Alternate Binary string using JS Check Single Flip for Same Bits using JS Min Flips for Uniform Characters using JS Perfect reversible string in JS Count Alphabet Characters using JS Float to String Conversion using JS String to Binary Conversion using JS Hard QuestionsThe Hard level includes articles that cover more intricate and less common tasks Find lexicographically next string using JS Print All Permutations of String in JSDivide Large Number in String Form using JS Longest Common Subsequence in JS Word Search in 2D Grid using JS Decode Encoded String Recursively using JS Check for Palindromic Rotation using JS Find kth non-repeating character using JS Generate Strings with Spaces using JS Find lexicographically next string using JS Generate binary strings from given pattern using JS Count strings with consecutive 1s in JS Find binary representation of next number using JS Reverse Only Consonants without affecting other character in JS Minimum Manipulations to make two string Anagram using JS Find ith index character in a binary string iteration using JS Add minimum characters at front to make string palindrome in JSJavaScript print shortest path to print a string on screen Longest Balanced Subsequence Length using JS Valid IP Address Format Check using JS Convert user input string into regular expression using JS Extract email addresses from a string using JS Mirror Characters in String using JSFind index of first occurrence of a substring using JSTruncate a string to a certain length using JS Print all permutations of given string using JS Print all strings that can be made by placing spaces using JS Print all subsequences of a string in JS Print frequency of each character in alphabetical order using JS Recursive Palindrome Check using JS Longest Balanced Subsequence Length using JS Recursive String Decode (Count-Substring) using JS Find index of last occurrence of a substring using JS Find kth non-repeating character using JS We have a complete list of Javascript String functions, to check those please go through this JavaScript String Complete Reference article. We have created an article of JavaScript Examples, and added list of questions based on Array, Object, Function, ..., etc. Please visit this JavaScript Examples to get complete questions based articles list of JavaScript. We have created a complete JavaScript Tutorial to help both beginners and experienced professionals. Please check this JavaScript Tutorial to get the complete content from basic syntax and data types to advanced topics such as object-oriented programming and DOM manipulation. Recent articles on JavaScript Comment More infoAdvertise with us V vishalkumar2204 Follow Improve Article Tags : JavaScript Web Technologies javascript-string Similar Reads JavaScript Programs JavaScript Programs contains a list of articles based on programming. This article contains a wide collection of programming articles based on Numbers, Maths, Arrays, Strings, etc., that are mostly asked in interviews.Table of ContentJavaScript Basic ProgramsJavaScript Number ProgramsJavaScript Math 13 min read JavaScript Array Examples JavaScript array is used to store multiple elements in a single variable. JavaScriptlet a = ["HTML", "CSS", "JS"] console.log(a)Output[ 'HTML', 'CSS', 'JS' ] Using New KeywordJavaScript// Declaring an array using Array Constructor let a = new Array(3) a[0] = "HTML" a[1] = "CSS" a[2] = "JS" console.l 3 min read Javascript Map Programming Examples A Javascript map is a collection of elements where each element is stored as a Key, value pair. Map objects can hold both objects and primitive values as either key or value. When we iterate over the map object it returns the key, and value pair in the same order as inserted.Javascript Map Programmi 3 min read JavaScript Math Programming Examples The JavaScript Math Object is used to perform mathematical operations on numbers. The Math object does not have a constructor. All properties and methods of Math are fixed/static. All properties and methods of Math are static and can be called by using Math as an object.JavaScript Math Programming E 2 min read JavaScript Number Programming Examples Javascript Numbers are primitive data types. Unlike other programming languages, Both integers and floating-point values are represented by JavaScript's number type. The IEEE-754 format is the one that is technically used by the JavaScript number type. Here, you donât need int, float, etc, to declar 3 min read JavaScript Object Programming Examples JavaScript Object is the collection of properties and the property is in key, value pair format. These objects are quite different from JavaScriptâs primitive data types (Number, String, Boolean, null, undefined, and symbol) in the sense that these primitive data types all store a single value each 6 min read JavaScript Set Programming Examples In JavaScript, the Set is a built-in collection that allows you to store unique values of any type, Set can store any type of value whether primitive or objects. It provides methods for adding, removing, and querying elements in an efficient way.JavaScriptlet s = new Set(["a", "b", "c"]); console.lo 1 min read JavaScript String Exercise JavaScript string is a primitive data type and is used for storing and manipulating a sequence of characters. It can contain zero or more characters within single or double quotes. This article contains a wide collection of JavaScript Programming examples based on String. JavaScriptlet s = "Geeksfor 7 min read Like