Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
# the method should return an array containing all strings that are either shorter thatn 6 caracters or begin with "e", But not both
def strange_words(array)
arr = []
i = 0
while i < array.length
char = array[i]
if (char.length < 6 || char[0] == "e") && !(char.length < 6 && char[0] == "e")
arr << char
end
i += 1
end
return arr
end
p strange_words(["taco", "eggs", "excellent"])
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more