Skip to content

Instantly share code, notes, and snippets.

@kkchu791
Last active March 16, 2016 18:23
Show Gist options
  • Save kkchu791/78f37a6ec4478de8c266 to your computer and use it in GitHub Desktop.
Save kkchu791/78f37a6ec4478de8c266 to your computer and use it in GitHub Desktop.
def capitalize_even_(word)
word.downcase
word.gsub /..?/, '3'
end
def capitalize_third(word)
word_array = word.split("")
word_array.map.with_index do |i, index|
if (index + 1) % 3 == 0
word_array[index].upcase
else
word_array[index]
end
end.join
end
p capitalize_third('kangaroo')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment