screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script src="https://unpkg.com/react@17.0.2/umd/react.development.js"></script> <script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.development.js"></script> <script src="https://unpkg.com/@babel/standalone@7.14.7/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const { useState } = React; function App() { const [strings, setStrings] = useState(["Hello123", "World456", "React789"]); const removeDigitsFromString = (str) => { return str.replace(/\d/g, ''); // Use a regular expression to remove digits globally } const filteredStrings = strings.map((str) => removeDigitsFromString(str) ); return ( <div className='container'> <h3>React Js Remove All Digits from list of Strings</h3> {JSON.stringify(strings)} <ul> {filteredStrings.map((str, index) => ( <li key={index}>{str}</li> ))} </ul> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { width: 600px; margin: 0 auto; box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 6px -1px, rgba(0, 0, 0, 0.06) 0px 2px 4px -1px; padding: 20px } </style> </body> </html>