<feat>(Aula1): resolução do teste 3 na atividade

This commit is contained in:
Gabriel Ferraz Nogueira 2022-11-04 14:01:58 -03:00
parent 43baf5092c
commit f727f8f115

View File

@ -59,6 +59,29 @@
uma array contendo 40 numeros aleatórios, retornar somente os números
pares divisíveis por 5, faça isso em javascript.
</p>
<script></script>
<script>
// array
// 40 length
// radom numbers
// return par / 5
function paresPor5() {
const numbers = [];
for (let i = 0; i < 40; i++) {
let numb = Math.floor(Math.random() * 100)
numbers.push(numb);
};
console.log(numbers);
const pares5 = []
numbers.forEach(element => {
if (element % 2 === 0 ) {
if (element % 5 === 0) {
pares5.push(element)
}
}
});
console.log(pares5);
}
paresPor5();
</script>
</body>
</html>