Funny Samples:
// 1. Phrase
function gap(a) {
return function(b) {
return function(c) {
return `${a[0].toUpperCase()}${a.slice(1)} ${b} ${c}`;
}
}
}
res = add('Hello')(['World'])('?');
console.log(res); // Hello World ?
// 2. Compliment generator
function makeCompliment(name) {
return function (adjective) {
return function (activity) {
return `${name}, you are so ${adjective} at ${activity} !`
}
}
}
let result = makeCompliment('Khojiakbar')('bad')('coding')
console.log(result); // Khojiakbar, you are so bad at coding !
// 3. Silly Story Maker
function makeStory(name) {
return function (noun){
return function (adverb) {
return `${name}, was looking at ${noun}, ${adverb}. But the ${noun} wasn't made ${adverb}.`
}
}
}
result = makeStory('John')('bread')('happily')
console.log(result); // John, was looking at bread, happily. But the bread wasn't made happily.
// 4. Make food
function makeFood(ingredient_one) {
return function(ingredient_two) {
return function(cooking_style){
return `Take ${ingredient_one} and ${ingredient_two} and mix them together with your hands and ${cooking_style} them.`
}
}
}
result = makeFood('cheese')('milk')('bake')
console.log(result); // Take cheese and milk and mix them together with your hands and bake them.
Top comments (0)