Skip to content

Instantly share code, notes, and snippets.

@jeyziel
Created August 24, 2017 21:44
Show Gist options
  • Save jeyziel/f35322287686909dcfb5e43c63db617b to your computer and use it in GitHub Desktop.
Save jeyziel/f35322287686909dcfb5e43c63db617b to your computer and use it in GitHub Desktop.
Curso-JavaScript-Super-Sayajin-Nível-1-Módulo-1-exercícios-aula1
const inverse = ( x ) => x *- 1
const add = ( y ) => ( x ) => x + y
const substract = ( y ) => ( x ) => add( inverse( y ) )( x )
const divide = ( y ) => ( x ) => {
let result = 0;
const subX = substract( x )
const add1 = add(1)
while ( y >= x ) {
result = add1( result )
y = subX( y )
}
return result;
}
console.log ( divide( 2 )( 2 ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment