← Back to challenges

Clear the Fog

JavaScriptHardformattingstringsregex

Instructions

Create a function which returns the word in the string, but with all the fog letters removed. However, if the string is clear from fog, return "It's a clear day!".

Examples

clearFog("sky") ➞ "It's a clear day!"

clearFog("fogfogFFfoooofftogffreogffesGgfOogfog") ➞ "trees"

clearFog("fogFogFogffoObirdsanffodthebffoeffoesGGGfOgFog") ➞ "birdsandthebees"

Notes

  • Hidden words won't include the letters f, o or g.
  • Hidden words are always in lowercase.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Apples and Bananas