Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Check if an Array Includes a Certain Element in JavaScript</title> </head> <body> <script> var fruits = ["Apple", "Banana", "Mango", "Orange", "Papaya"]; document.write(fruits.includes("Banana") + "<br>"); // Outputs: true document.write(fruits.includes("Coconut") + "<br>"); // Outputs: false document.write(fruits.includes("Orange") + "<br>"); // Outputs: true document.write(fruits.includes("Cherry")); // Outputs: false </script> </body> </html>