The Data Scrub
Easy+20 XP
Mission Briefing
The data sensors keep picking up strange, empty static at the beginning and end of incoming transmissions. You must scrub this dirty data before it reaches the main console.
The Concept: String Cleaning
The .trim() method removes whitespace (spaces, tabs, newlines) from both the beginning and the end of a string. It leaves any spaces in the middle completely untouched.
Example: " hello world ".trim(); // Returns "hello world"
The Objective
Your function receives a string input that might be wrapped in annoying whitespace.
- Clean the string by stripping away the leading and trailing spaces using
.trim(). - Return the sparkling clean string.
01EXAMPLE 1
Input
input = " CodeMagicX "Output
"CodeMagicX"Constraints
- Remove lead/trail spaces only.
FundamentalsStrings
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
input" test "
Expected Output
test
Click RUN to test your solution