Created
July 13, 2011 08:08
-
-
Save Chris927/1079916 to your computer and use it in GitHub Desktop.
Reverse a string in CoffeeScript
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
reverse = (s) -> | |
if s.length < 2 then s else reverse(s[1..-1]) + s[0] | |
s = "Hello" | |
console.log "s=#{s}, s.reverse=#{reverse(s)}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment