Space at the end of a word

1

I created an application in react native and it does online searches via POST. It works fine, the point is that some gadgets include a space at the end of words, eg:

The user types natação , but the cell phone sends natação_ with a space at the end (I put underline just to make it easier to see).

How do I remove the space from the end before making the query?

    
asked by anonymous 28.01.2018 / 14:18

1 answer

4

Call the method trim of the string before using it.

Try it out:

let foo = 'natação ';
console.log(foo.trim());

The trim method removes all spaces at the end of the string if there is more than one.

    
28.01.2018 / 14:22