Get Primitive And Pairs Numbers From An Array In Javascript

How To Get Primitive And Pairs Numbers Using JavaScript

Javascript Array - Primitive And Pairs Numbers



In This Javascript Tutorial we will see How To Get The Pairs And Primitive Numbers From An Array In JS Using Netbeans Editor .




Project Source Code:

<!DOCTYPE html>
<html>
    <head>
        <title>JavaScript: Primitive And Pairs Numbers</title>
        <meta charset="windows-1252">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <script>
            
            var arr = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,19,21,23,25,27];
            
            for(i = 0; i < arr.length; i++)
            {
                if(arr[i]%2 === 0)
                {
                    document.write("<p style='color:green'>Pair Number "+ arr[i] +"</p>");
                }
                
                else
                {
                    document.write("<p style='color:red'>Primitive Number "+ arr[i] +"</p>");
                }
            }
            
        </script>    
    </body>
</html>




Share this

Related Posts

Previous
Next Post »