# How does variable.trim(); work?

**URL:** <https://discourse.codecombat.com/t/how-does-variable-trim-work/22009>\
**Category:** Level Help\
**Created:** [June 3, 2020, 11:39pm UTC](https://discourse.codecombat.com/t/how-does-variable-trim-work/22009 "2020-06-03T23:39:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bubble\_Animations](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bubble_animations/32/11708_2.png) [@Bubble\_Animations](https://discourse.codecombat.com/u/Bubble_Animations)\
**Post date:** [June 3, 2020, 11:39pm UTC](https://discourse.codecombat.com/t/how-does-variable-trim-work/22009/1 "2020-06-03T23:39:37Z")

</div>

Hello!

Near the end of Cloudrip Mountain, the levels want us to modify strings and count the number of “whitespaces”.  
What are whitespaces and how does variable.trim() work?

Thank you in advance 😄 ❤

---

<div class="post-metadata">

**Author:** ![Bubble\_Animations](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bubble_animations/32/11708_2.png) [@Bubble\_Animations](https://discourse.codecombat.com/u/Bubble_Animations)\
**Post date:** [June 4, 2020, 12:17am UTC](https://discourse.codecombat.com/t/how-does-variable-trim-work/22009/2 "2020-06-04T00:17:34Z")

</div>

I think I might have figured it out  
White spaces are just spaces (" ") that are at the beginning or end of a message, not in between  
It just deletes the white spaces and returns it  
(dashes are white spaces in this example)  
“- - - Hello there - -”  
After trimming: “Hello there”
