Convert a string to a new string

A simple one!

There are many ways to convert a string to a new string, depending on what you want to do with the original string. Here are a few examples:

  1. Uppercase: Convert a string to uppercase using the toUpperCase() method:
    const originalString = "hello";
    const newString = originalString.toUpperCase(); // "HELLO"
  2. Lowercase: Convert a string to lowercase using the toLowerCase() method:
    const originalString = "HELLO";
    const newString = originalString.toLowerCase(); // "hello"
  3. Reverse: Reverse the order of characters in a string using the split() and join() methods:
    const originalString = "hello";
    const newString = originalString.split("").reverse().join(""); // "olleh"
  4. Trim: Remove whitespace from the beginning and end of a string using the trim() method:
    const originalString = "   hello   ";
    const newString = originalString.trim(); // "hello"
  5. Replace: Replace a substring with another string using the replace() method:
    const originalString = "hello world";
    const newString = originalString.replace("world", "universe"); // "hello universe"
  6. Substring: Extract a portion of a string using the substring() method:
    const originalString = "hello world";
    const newString = originalString.substring(6); // "world"
  7. Concatenate: Combine two strings using the + operator:
    const originalString1 = "hello";
    const originalString2 = " world";
    const newString = originalString1 + originalString2; // "hello world"

    These are just a few examples of how you can convert a string to a new string. There are many more methods and techniques available in JavaScript!