1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| var substring,
substringFromHello,
slice,
sliceDeclaredArray;
substring = f(String.prototype.substring);
substringFromHello = substring('hello world!');
console.log(substringFromHello([6, 11])); // 'world'
// or
substring = f(String.prototype.substring);
substringFromHello = substring('hello world!', 6);
console.log(substringFromHello([11])); // 'world'
// or
slice = f(Array.prototype.slice);
sliceDeclaredArray = slice([1, 2, 3, 4, 5]);
console.log(sliceDeclaredArray([2, 4])); // [3, 4]
/*
constraints :
- the f function
- takes 1 argument, a function (or object method) and must work with any other
- returns a function which
- takes one or more arguments, where the first is the value to treat with the final function
and pass the rest to the final function
- returns a function which
- takes any number of arguments, as array or arguments object
- returns the result
- no global vars
- no more than 40 characters
- no more than 2 words, except your own var names
- must be valid in current standard JS (ES6)
*/ |