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 str = "hello, world!"; // Replace with your string const isFirstLetterUppercase = str => { if (str.length === 0) { return false; } const firstCharCode = str.charCodeAt(0); return firstCharCode >= 65 && firstCharCode <= 90; }; const capitalizeFirstLetter = str => { if (isFirstLetterUppercase(str)) { return str; } else { const firstCharCode = str.charCodeAt(0); const capitalizedFirstLetter = String.fromCharCode(firstCharCode - 32); return capitalizedFirstLetter + str.slice(1); } }; const modifiedString = capitalizeFirstLetter(str); return ( <div className='container'> <h3 className='title'> use charCodeAt() Method</h3> <p className='string-info'>String: {str}</p> <p className='uppercase-check'>Is the first letter uppercase? {isFirstLetterUppercase(str).toString()}</p> <p className='modified-string'>Modified String: {modifiedString}</p> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { font-family: Arial, sans-serif; padding: 20px; border-radius: 5px; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); max-width: 600px; margin: 0 auto; text-align: center; } .title { font-size: 24px; color: #333; margin: 0; padding-bottom: 10px; } .string-info, .uppercase-check, .modified-string { font-size: 18px; color: #555; margin: 10px 0; } .modified-string { color: #00a0e4; } </style> </body> </html>