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"> function App() { const numberToRound = 5.6789; const roundedNumber = Math.round(numberToRound * 100) / 100; // Rounds to two decimal places return ( <div className='container'> <h3 className='title'>React Js Round Number Two Decimal Places | Math.round() Method</h3> <p className='original-number'>Original Number: {numberToRound}</p> <p className='rounded-number'>Rounded Number: {roundedNumber}</p> </div> ); } ReactDOM.render(<App />, document.getElementById('app')); </script> <style> /* Style the container */ .container { max-width: 600px; margin: 0 auto; padding: 20px; text-align: center; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); } /* Define styles for the title */ .title { margin-bottom: 10px; color: #333; } /* Define styles for the original number */ .original-number { font-size: 18px; color: #555; } /* Define styles for the rounded number */ .rounded-number { font-size: 18px; color: #555; margin-top: 10px; } /* Add some spacing between paragraphs */ p { margin: 10px 0; } </style> </body> </html>