Check if 10 variables are between 0 and 1 - Javascript Array

Javascript examples for Array:filter

Description

Check if 10 variables are between 0 and 1

Demo Code

ResultView the demo in separate window

<html lang="en">
   <head></head>
   <body translate="no"> 
      <script>
      var allScores = [4, 2, 'a', null, null, '7', ''];
var errorScores = allScores.filter(function(s) {
  return !(parseInt(s) >= 0 && parseInt(s) <= 1)
});//  w  ww.  j  a  v a 2 s.  c om

if (errorScores.length > 0) {
  document.write('something went wrong!');
}
    
      </script>  
   </body>
</html>

Related Tutorials