screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const { useState } = React; function App() { const [originalArray, setOriginalArray] = useState(["Hello", "World", "React", "JS"]); const convertArrayToLowerCase = () => { const lowercaseArray = originalArray.map(item => item.toLowerCase()); setOriginalArray(lowercaseArray); }; return ( <div className='container'> <h2>React Js Array Element to Lowercase</h2> <button onClick={convertArrayToLowerCase}>Convert to Lowercase</button> <p>{JSON.stringify(originalArray)}</p> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> * { box-sizing: border-box; } .container { padding: 20px; border-radius: 8px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); text-align: center; max-width: 600px; margin: 0 auto; } button { display: inline-block; padding: 10px 20px; background-color: #3498db; color: #fff; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; transition: background-color 0.3s ease; } button:hover { background-color: #2980b9; } </style> </body> </html>