Skip to content

Instantly share code, notes, and snippets.

@suissa
Created February 22, 2020 03:51
Show Gist options
  • Save suissa/91f83d45acfaf409f6eae50975a356f9 to your computer and use it in GitHub Desktop.
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
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