I have seen a way of testing whether a string is a pangram -- a sentence containing every letter of the alphabet -- but I didn't quite understand it. I want to know why my way isn't working.
def is_pangram(string)
alpha = ("a".."z").to_a
i = 0
while i < string.length
if string.downcase[i] == alpha.any?
alpha.delete(string.downcase[i])
end
i += 1
end
if alpha.length > 0
puts "This string is not a pangram"
else
puts "This string is a pangram"
end
puts alpha.length
puts alpha
end
is_pangram("The quick brown fox jumps over the lazy dog")