Created
December 20, 2021 20:20
-
-
Save m4n50n/6cb87357249d5bed8b4e28181c29b292 to your computer and use it in GitHub Desktop.
Calculating with Functions - Codewars Kata
This file contains 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
function zero(param) { return (!param) ? 0 : param(0); } // param = plus / minus ... | |
function one(param) { return (!param) ? 1 : param(1); } | |
function two(param) { return (!param) ? 2 : param(2); } | |
function three(param) { return (!param) ? 3 : param(3); } | |
function four(param) { return (!param) ? 4 : param(4); } | |
function five(param) { return (!param) ? 5 : param(5); } | |
function six(param) { return (!param) ? 6 : param(6); } | |
function seven(param) { return (!param) ? 7 : param(7); } | |
function eight(param) { return (!param) ? 8 : param(8); } | |
function nine(param) { return (!param) ? 9 : param(9); } | |
function plus(inicial_num) { | |
return function (final_num) { | |
return inicial_num + final_num; | |
} | |
} | |
function minus(inicial_num) { | |
return function (final_num) { | |
return final_num - inicial_num; | |
} | |
} | |
function times(inicial_num) { | |
return function (final_num) { | |
return inicial_num * final_num; | |
} | |
} | |
function dividedBy(inicial_num) { | |
return function (final_num) { | |
return parseInt(final_num / inicial_num); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment