Skip to content

Instantly share code, notes, and snippets.

View ChousinRahit's full-sized avatar

K Chousin Rahit ChousinRahit

  • ThinkJs
  • Bengaluru
View GitHub Profile
// 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"
// 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"
// 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!!"
// 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"