--
You received this message because you are subscribed to the Google Groups "Ruby Srbija" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubysrbija+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubysrbija/51424144-4cb9-4019-a5dd-88990dfd2583n%40googlegroups.com.
def is_valid_name(str)
parts = str.split(" ")
if parts.length < 2
false
end
parts.each do |part|
unless is_capitalized(part)
false
end
end
true
end
def is_capitalized(word)
if word[0] == word[0].upcase && word[1..-1] == word[1..-1].downcase
true
else
false
end
end
puts is_valid_name("Kush Patel") # => true
puts is_valid_name("DanieL") # => false
puts is_valid_name("Robert Downey Jr") # => true
puts is_valid_name("ROBERT DOWNEY JR") # => false
Vraca mi sve true, ne znam gde sam pogresio? Pokusavam da shvatim logiku ovoga, jer deluje mi da je kod ispravan, tj. vraca mi sve true
To view this discussion on the web visit https://groups.google.com/d/msgid/rubysrbija/CAFpsJjy%2BrkxjBCPBddhsMUHxC-E2tapWEYG6E2FtpHm1C6kUzQ%40mail.gmail.com.
def is_capitalized(word)
word == word.downcase.capitalize
end
To view this discussion on the web visit https://groups.google.com/d/msgid/rubysrbija/CAFq%3D9czUriUpjVbov%3DmcYN34%2B2wQbrBigw_JD7iszGP_yHeSnQ%40mail.gmail.com.
You received this message because you are subscribed to a topic in the Google Groups "Ruby Srbija" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubysrbija/d5CEYgY3fdk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rubysrbija+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubysrbija/CABOFUs%3Dv4H89ju75vNGUuq8rK-_PPKVrxPbGDR7bYPXy7hMXAQ%40mail.gmail.com.
def is_capitalized(word)
word == word.capitalize
end
To view this discussion on the web visit https://groups.google.com/d/msgid/rubysrbija/CAFq%3D9cxrNFGdLWq08546yXfMB_J-nbQJfLp5cXnjrhV%3D%3DXsL2A%40mail.gmail.com.
def capitalized?(word)
word == word.capitalize
end