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"> function kebabToCamel(str) { let camelCaseStr = ""; let nextUpperCase = false; for (let i = 0; i < str.length; i++) { const currentChar = str.charAt(i); if (currentChar === "-") { nextUpperCase = true; } else { camelCaseStr += nextUpperCase ? currentChar.toUpperCase() : currentChar; nextUpperCase = false; } } return camelCaseStr; } function App() { const kebabCaseString = "font-awesome-icons"; const camelCaseString = kebabToCamel(kebabCaseString); return ( <div className="container"> <h3>React Js Convert Kebab Case to CamelCase without Regex</h3> <p>Kebab-case string: {kebabCaseString}</p> <p>CamelCase string: {camelCaseString}</p> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> /* Assuming you are using React (as indicated by the className attribute) */ .container { max-width: 400px; margin: 0 auto; padding: 20px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); font-family: Arial, sans-serif; } </style> </body> </html>