Skip to content

Instantly share code, notes, and snippets.

@AdamSanderz
Forked from alimir1/checkIfPalindrome.swift
Created September 7, 2019 09:27
Show Gist options
  • Save AdamSanderz/a49ca842d4d62006355df493fd179801 to your computer and use it in GitHub Desktop.
Save AdamSanderz/a49ca842d4d62006355df493fd179801 to your computer and use it in GitHub Desktop.
Check if string is palindrome Swift 3
func isPalindrome(_ word: String) -> Bool {
let word = word.lowercased().characters.filter{ $0 != " " }
for (i, character) in word.enumerated() {
if character != word[word.count-i-1] {
return false
}
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment