Created
February 22, 2020 03:51
-
-
Save suissa/91f83d45acfaf409f6eae50975a356f9 to your computer and use it in GitHub Desktop.
Demonstração de como criar operações básicas de matemática usando Arrays
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
const crieUmaListaDeTamanho = (tam) => ({ | |
ePreenchaCom: (num) => Array(tam).fill(num) | |
}) | |
const somar = (total, num) => total + num | |
const somatorio = (lista) => lista.reduce(somar, 0) | |
const multiplicar = (x, y) => | |
somatorio( | |
crieUmaListaDeTamanho(x).ePreenchaCom(y) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment