Check String for Spaces

Published by Pickle in

Create a function that returns true if a string contains any spaces.

Examples

HasSpaces("hello") ➞ false

HasSpaces("hello, world") ➞ true

HasSpaces(" ") ➞ true

HasSpaces("") ➞ false

HasSpaces(",./!@#") ➞ false

Notes

  • An empty string does not contain any spaces.
  • Try doing this without RegEx.
Watch a quick demo on how Edabit works.