Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Search an Array based on Certain Condition and Find Index</title> </head> <body> <script> let arr = [1, 0, 3, 1, false, 5, 1, 4, 7]; let result = arr.findIndex(function(element){ return element > 6; }); document.write(result); // Prints: 8 </script> </body> </html>