Skip to content

Instantly share code, notes, and snippets.

@ChousinRahit
Created September 3, 2023 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChousinRahit/6ebde05a7d21fbe0dba6dfd38d33a05e to your computer and use it in GitHub Desktop.
Save ChousinRahit/6ebde05a7d21fbe0dba6dfd38d33a05e to your computer and use it in GitHub Desktop.
// 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"
// replace("", "a-z") ➞ ""
// Notes
// 1 - The range will always be in order, a.k.a. for m-n, character m will always come before or equal n.
// 2 - Strings will be in lower case letters only.
// 3 - Return an empty string if the input is an empty string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment