Remove all whitespaces

Easy
10
75.5% Acceptance

In this coding challenge, you will be implementing a function called removeWhitespaces(string) that takes a string as the input. The function should return the string with all the whitespace removed.

Instructions

  • If the input string is empty, then return an input string.
  • Remember to account for \n and \t.

Example test cases

removeWhitespaces('Hello, World!'); // Output: 'Hello,World!' removeWhitespaces(' This is a sentence.\nIt contains some whitespace. '); // Output: 'Thisisasentence.Itcontainssomewhitespace.' removeWhitespaces('\t \n\n'); // Output: ''