screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="https://unpkg.com/react@17.0.2/umd/react.production.min.js"></script> <script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.production.min.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"> function App() { const inputString = "United State America"; // Split the input string into words const words = inputString.split(' '); // Map over the words and extract the first letter of each word const firstLetters = words.map(word => word[0]); // Join the first letters back into a string const resultString = firstLetters.join(''); return ( <div className='container'> <h3 className='title'>React Js Get first letter of each word in a string</h3> <p className='input-text'>Input String: {inputString}</p> <p className='result-text'>First Letters: {resultString}</p> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { max-width: 500px; margin: 0 auto; text-align: center; padding: 20px; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } /* Styles for the title */ .title { font-size: 24px; font-weight: bold; margin-bottom: 10px; color: #333; } /* Styles for the input-text */ .input-text { font-size: 16px; color: #555; margin-bottom: 5px; } /* Styles for the result-text */ .result-text { font-size: 18px; font-weight: bold; color: #007bff; } </style> </body> </html>