Created
August 24, 2017 21:44
-
-
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
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 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