Skip to content

Instantly share code, notes, and snippets.

@oscarito9410
Created June 9, 2023 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oscarito9410/3117dce764994960f8a08ee0aca57dbb to your computer and use it in GitHub Desktop.
Save oscarito9410/3117dce764994960f8a08ee0aca57dbb to your computer and use it in GitHub Desktop.
fun reverseString(word: String): String {
var result = CharArray(word.length)
var counter = 0
for(i in word.length - 1 downTo 0) {
result[counter] = word[i]
counter++
}
return String(result)
}
fun main() {
print(reverseString("Hello, World!"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment