This file contains hidden or 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
//link https://www.codewars.com/kata/your-order-please | |
//Introduction | |
// Your task is to sort a given string. Each word in the string will contain a single number. This number is the position the word should have in the result. | |
// Note: Numbers can be from 1 to 9. So 1 will be the first word (not 0). | |
// If the input string is empty, return an empty string. The words in the input String will only contain valid consecutive numbers. | |
//Examples | |
// "is2 Thi1s T4est 3a" --> "Thi1s is2 3a T4est" | |
// "4of Fo1r pe6ople g3ood th5e the2" --> "Fo1r the2 g3ood 4of th5e pe6ople" | |
// "" --> "" |
This file contains hidden or 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
//Introduction | |
// Your task in order to complete this Kata is to write a function which formats a duration, given as a number of seconds, in a human-friendly way. | |
// The function must accept a non-negative integer. If it is zero, it just returns "now". Otherwise, the duration is expressed as a combination of years, days, hours, minutes and seconds. | |
// It is much easier to understand with an example: | |
// formatDuration(62) // returns "1 minute and 2 seconds" | |
// formatDuration(3662) // returns "1 hour, 1 minute and 2 seconds" | |
// For the purpose of this Kata, a year is 365 days and a day is 24 hours. | |
// Note that spaces are important. |
This file contains hidden or 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 exp(num,op){ | |
if(!op){return num} | |
return op(num) | |
} | |
function zero(op) { return exp(0,op) } | |
function one(op) {return exp(1,op)} | |
function two(op) {return exp(2,op)} | |
function three(op) {return exp(3,op)} | |
function four(op) {return exp(4,op)} |