Skip to content

Instantly share code, notes, and snippets.

@dmitrysurkin
Created January 1, 2021 11:59
Show Gist options
  • Save dmitrysurkin/9e1c1bf9d7b06e19092e81bf182deeb2 to your computer and use it in GitHub Desktop.
Save dmitrysurkin/9e1c1bf9d7b06e19092e81bf182deeb2 to your computer and use it in GitHub Desktop.
1-power.js
// 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