<p>Original String: {originalString}</p> " />

PASSWORD RESET

Your destination for complete Tech news

How to convert string to lowercase in React JS?

1.89K 0
< 1 min read

Converting a string to lowercase in React is done using JavaScript’s built-in toLowerCase() method. Here’s how you can achieve this:

import React from 'react';

function StringToLowercase() {
  const originalString = "Hello World";
  const lowercaseString = originalString.toLowerCase();

  return (
    <div>
      <p>Original String: {originalString}</p>
      <p>Lowercase String: {lowercaseString}</p>
    </div>
  );
}

export default StringToLowercase;

In this example, the StringToLowercase component converts the originalString to lowercase using the toLowerCase() method. The converted string is then displayed in the output.

Replace "Hello World" with your own string, and the component will display both the original and lowercase versions of it.

Keep in mind that toLowerCase() does not modify the original string; instead, it returns a new string with all characters converted to lowercase.

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.