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
// 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" |
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
// https://edabit.com/challenge/Mc6Xi4PRw7fDzeMDB | |
// Create a function that takes a string and returns a string in which each character is repeated once. | |
// Examples | |
// doubleChar("String") ➞ "SSttrriinngg" | |
// doubleChar("Hello World!") ➞ "HHeelllloo WWoorrlldd!!" |
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
// Hiding the Card Number | |
// Write a function that takes a credit card number and only displays the last four characters. | |
// The rest of the card number must be replaced by ************. | |
// Examples | |
// cardHide("1234123456785678") ➞ "************5678" | |
// cardHide("8754456321113213") ➞ "************3213" |
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
// Move Capital Letters to the Front | |
// Create a function that moves all capital letters to the front of a word. | |
// Examples | |
// capToFront("hApPy") ➞ "APhpy" | |
// capToFront("moveMENT") ➞ "MENTmove" |
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
// Reverse Words in a String | |
// Given an input string, reverse the string word by word, the first word will be the last, and so on. | |
// Examples | |
// reverseWords(" the sky is blue") ➞ "blue is sky the" | |
// reverseWords("hello world! ") ➞ "world! hello" |
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
// Extend the Vowels | |
// Create a function that takes a word and extends all vowels by a number num. | |
// extendVowels("Hello", 5) ➞ "Heeeeeelloooooo" | |
// extendVowels("Edabit", 3) ➞ "EEEEdaaaabiiiit" | |
// extendVowels("Extend", 0) ➞ "Invalid" |
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
// Change Every Letter to the Next Letter | |
// Write a function that changes every letter to the next letter: | |
// "a" becomes "b" | |
// "b" becomes "c" | |
// "d" becomes "e" | |
// and so on ... | |
// move("hello") ➞ "ifmmp" |
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
// Longest Word | |
// Write a function that finds the longest word in a sentence and returns it. | |
// If two or more words are the biggest, return the word closest to the start of the sentence. | |
// Characters such as apostrophe, commas, periods, etc count as letters (e.g.O'Connor is 8 characters long). | |
// Examples | |
// longestWord("Hello darkness my old friend") ➞ "darkness" | |
// longestWord("Hello there mate") ➞ "Hello" |
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
// Stretched Words | |
// Write a function that takes a string, and returns a new string with any duplicate consecutive letters removed. | |
// Examples | |
// unstretch("ppoeemm") ➞ "poem" | |
// unstretch("wiiiinnnnd") ➞ "wind" | |
// unstretch("ttiiitllleeee") ➞ "title" |
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
// Replacing Letters with Hashes | |
// Write a function that replaces all letters within a specified range with the hash symbol #. | |
// Examples | |
// replace("abcdef", "c-e") ➞ "ab###f" | |
// replace("rattle", "r-z") ➞ "#a##le" | |
// replace("microscopic", "i-i") ➞ "m#croscop#c" |
OlderNewer