Check out example codes for "how to get rid of excess space in swift". It will help you in understanding the concepts better.

Code Example 1

let freedSpaceString = str.filter {!$0.isWhitespace}

Code Example 2

let str = "  Taylor Swift  "
let trimmed = str.trimmingCharacters(in: .whitespacesAndNewlines) // prints "Taylor Swift"

Learn ReactJs, React Native from akashmittal.com