How to Remove all Spaces from String in React

 sometimes we need to remove all spaces from string. In this artcle, we’re going to remove all spaces from string in React.

import React from "react";

function App() {

  var myStr = " Wel come To My Note Paper ";
  var newStr = myStr.replace(/\s/g, "");

  return(
    <div>
      <p><strong>String: </strong>{myStr}</p>
      <p><strong>Without Spaces: </strong>{newStr}</p>
    </div>
  )
}

export default App;

Leave a comment

Your email address will not be published. Required fields are marked *