swag

Ahmed Khaled · @nemoload · about 3 years

Takes a text and returnstExT

def swag(text)
text = ARGV.join(' ')
ignore = true
res = ''
text.downcase.each_char do |c|
res.concat(ignore ? c : c.capitalize)
ignore = !ignore
end
res
end
1 · 1 · 0
ahmed · @abo-elleef · almost 3 years

you can do the same without flags and new string in memory def swag(text) text = ARGV.join(‘ ‘) text.split(‘’).map.with_index do |char, index| index.even? ? char.upcase : char.downcase end.join(‘’) end