We're a place where coders share, stay up-to-date and grow their careers.
Ruby, not optimal 🙃
def to_weird_case(string) if string.include? " " string.split(" ").map { |word| word.split("") }.each do |letter_array| letter_array.each_with_index do|letter, index| letter.upcase! if index % 2 == 0 }}.map(&:join).join(" ") end end else string.split("").each_with_index do |letter, index| letter.upcase! if index % 2 == 0 end.join end end
Ruby, not optimal 🙃