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://cdn.jsdelivr.net/npm/@babel/standalone@7.14.6/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel" data-type="module"> const { useState } = React; const App = () => { // Define the array const myArray = ["apple", "banana", "orange", "grape"]; // Get value by index const specificIndex = 2; const valueAtIndex = myArray[specificIndex]; return ( <div className="container"> <h1>React Js Access Array Value by Index</h1> <p>Array: {myArray.join(", ")}</p> <p> Value at index {specificIndex}: {valueAtIndex} </p> </div> ); }; ReactDOM.render(<App />, document.getElementById("app")); </script> <style> body { margin: 0; } .container { max-width: 800px; margin: 0 auto; padding: 20px; font-family: Arial, sans-serif; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); position: relative; } </style> </body> </html>