Created
January 1, 2021 11:59
-
-
Save dmitrysurkin/9e1c1bf9d7b06e19092e81bf182deeb2 to your computer and use it in GitHub Desktop.
1-power.js
This file contains hidden or 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
// Define function power - an alias to Math.pow(). | |
const power = (base, power) => Math.pow(base, power); | |
// Implement function `square(n)`, which returns square of its argument. | |
// The function may or may not reuse function `power`. | |
const square = num => power(num, 2); | |
// Implement function `cube(n)` using partial application | |
// The function should return power of three for the given argument. | |
const cube = power.bind(null , 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment