Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions codewars/6kyu/function-composition/koronya.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// [JS][6kyu] Function Composition
// function-composition
// https://www.codewars.com/kata/5421c6a2dda52688f6000af8/train/javascript

// prettier-ignore
const compose = (f, g) => (...args) => f(g(...args))

function compose2(f, g) {
return function () {
return f(g(...arguments))
}
}

const add = function (a) {
return a + 1
}
const id = function (a) {
return a
}

compose(add, id)(0)

const add1 = function (a) {
return a + 1
}
const addAll3 = function (a, b, c) {
return a + b + c
}

compose(add1, addAll3)(1, 2, 3)