How to replace lowercase letters with an other character in JavaScript ? Last Updated : 20 Jun, 2023 Comments Improve Suggest changes Like Article Like Report Given a string and the task is to replace all lowercase letters from a string with the other characters in JavaScript. There are some approaches to replace the character that are described below: JavaScript replace() Method: This method searches a string for a defined value, or a regular expression, and returns a new string with the replaced defined value. Syntax: string.replace(searchVal, newvalue) Parameters: searchVal: It is a required parameter. It specifies the value or regular expression, that is going to replace by the new value.newvalue: It is a required parameter. It specifies the value to be replaced by the search value. Return value: It returns a new string that matches the pattern specified in the parameters. Example 1: This example replaces the lowercase letters with . (dot) using replace() method. JavaScript var str = "WELCOMEiTOgGEEKS"; console.log(str.replace(/[a-z]/g, ".")); OutputWELCOME.TO.GEEKS Example 2: This example replaces the lowercase letters with (' ')(space) by going to the each character and checking if it is lowercase. JavaScript var str = "THISiISgGEEKSFORGEEKS!"; function gfg_Run() { let newStr = ""; for (let i = 0; i < str.length; i++) { if (str.charCodeAt(i) >= 97 && str.charCodeAt(i) <= 122) { newStr += ' '; } else { newStr += str[i]; } } console.log(newStr); } gfg_Run(); OutputTHIS IS GEEKSFORGEEKS! Example 3: In this example, we will use reduce method to replace all the lowerCase characters from string. JavaScript let str = "THISiISgGEEKSFORGEEKS!"; function check(x) { if (x >= 'a' && x <= "z") return false; return true; } function gfg_Run() { let newStr = [...str].reduce((accu, x) => check(x) ? accu + x : accu + ".", ''); console.log(newStr); } gfg_Run(); OutputTHIS.IS.GEEKSFORGEEKS! Comment More infoAdvertise with us Next Article How to replace lowercase letters with an other character in JavaScript ? P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Similar Reads How to replace a character at a particular index in JavaScript ? To replace a character from a string there are popular methods available, the two most popular methods we are going to describe in this article. The first method is by using the substr() method. And in the second method, we will convert the string to an array and replace the character at the index. 4 min read How to returns a passed string with letters in alphabetical order in JavaScript ? Let's say we need to convert the string into alphabetical order. For example: geeksforgeeks -> eeeefggkkorss Approach: The task is to create a function that takes a string and returns the alphabetical order of that string. Hence to achieve this we will go under the split, sort, and join method in 2 min read Replace special characters in a string with underscore (_) in JavaScript We will explore several methods to replace special characters in a string with an underscore (_) in JavaScript. Special characters are non-alphanumeric symbols, and replacing them is a common requirement in various use cases such as sanitizing input or formatting file names.Table of ContentJavaScrip 2 min read How to replace a portion of strings with another value in JavaScript ? In JavaScript, replacing a portion of strings with another value involves using the `replace()` method or regular expressions. This process is essential for text manipulation tasks like formatting, sanitization, or dynamic content generation in web development and data processing applications. We ca 3 min read How to Lowercase a String in JavaScript ? In JavaScript, converting a string to lowercase means transforming all the characters in the string to their lowercase equivalents. This operation is often used to ensure consistent comparison or formatting of text. Below are the approaches used to Lowercase a string in JavaScript: Table of Content 2 min read Like