Skip to content

Instantly share code, notes, and snippets.

@yickson
Last active March 9, 2020 17:12
Show Gist options
  • Save yickson/1b14e3e434e939b04c5408189d4933ad to your computer and use it in GitHub Desktop.
Save yickson/1b14e3e434e939b04c5408189d4933ad to your computer and use it in GitHub Desktop.
Función que suma un arreglo y retorna una funcion que recibe la sumatorio del arreglo inicial
const miArray = [1, 2, 3, 4, 5];
const sum = (arrayInt) => {
return arrayInt.reduce((accum , current) => (accum + current), 0);
}
const suma = (arr2) => (func) => (func(sum(arr2)));
// Ejemplo de uso
suma(miArray) (
resultado => console.log(resultado)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment