Jump to content
Fórum Script Brasil
  • 0

Array em JavaScript SOCORROOOO


Question

Estou precisando fazer o seguinte exercicio: 9Em JavaScript, usando apenas laços de repetição e condicionais, crie uma função - retornaApenasNumerosPares - que receba como parâmetro um array de números inteiros e retorne apenas os pares.

 

Porem não estou conseguindo colocar o array, segue meu codigo

 

<!DOCTYPE html>
<html>
    <meta charset="utf-8">
    <title></title>
    
    <script>
        function retornaApenasNumerosPares(){
            var num =document.getElementById("numero").value;
            var int_num =Number(num);
            var lista_par=[];
            
 
            if(int_num%2 == 0)
            {
                alert("par");
        
            } 
 
           
 
        }
 
    </script>
    <head>
        <body>
 
            <input type="text" id="numero">
            <button onclick="retornaApenasNumerosPares();">verifica</button>
        </body>
    </head>
</html>
Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      148905
    • Total Posts
      644996
×
×
  • Create New...