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"> <title>Check Array Element in Webpage</title> </head> <body> <p>Array : [1,2,3,4,5]</p> <p>Check Element : 3</p> <p id="output"></p> <button onclick="checkElement()">Clic me to Check</button> <script> const array = [1, 2, 3, 4, 5]; const element = 3; let outputDiv = document.getElementById('output'); function checkElement() { if (array.includes(element)) { outputDiv.innerHTML = 'Element is present in the array'; } else { outputDiv.innerHTML = 'Element is not present in the array'; } } </script> </body> </html>