Array List Item Search with a for loop - Javascript Array

Javascript examples for Array:indexOf

Description

Array List Item Search with a for loop

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from  www  .  j ava2  s . c  om*/

var numbers = [16, 45, 34, 89, 5, 48, 54, 8, 79];
for (var i = 0; i < numbers.length; i++) {
    if (numbers[i] < 10) {
        console.log(numbers.indexOf(numbers[i]));
    }
}


    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials