Last active
July 1, 2019 17:42
-
-
Save raloliver/4666321f1accb2403ca7a385b0de0267 to your computer and use it in GitHub Desktop.
Imperativa x Funcional
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Programação Imperativa*/ | |
var list = [1,2,3,4,5,6]; | |
var pares = []; | |
for(var i = 0; i < list.length; i++){ | |
if(list[i] % 2 === 0){ | |
pares.push(list[i]); | |
} | |
} | |
/* Programação Funcional */ | |
var list = [1,2,3,4,5,6]; | |
var pares = list.filter(x => x % 2 === 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment