Created
November 10, 2017 05:10
-
-
Save volkanbicer/5578878691c400457c456ccf2641c574 to your computer and use it in GitHub Desktop.
Function that takes a string as input and returns the string reversed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func reverseString(_ s: String) -> String { | |
var reversed = "" | |
var stringArray = Array(s.characters) | |
var n = s.characters.count | |
for i in 0..<stringArray.count{ | |
reversed.append(stringArray[n-1-i]) | |
} | |
return reversed | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment