Skip to content

Instantly share code, notes, and snippets.

@husseinagrama
Created March 15, 2017 22:55
Show Gist options
  • Save husseinagrama/69a1dea62c8156799926cf2720b77ec9 to your computer and use it in GitHub Desktop.
Save husseinagrama/69a1dea62c8156799926cf2720b77ec9 to your computer and use it in GitHub Desktop.
array = ["Alphabet", "aardvark", "anarchy", "purple", "apple", "avalanche", "potato"]
new_array = []
array.each do |name|
find = name.split("")
count = 0
find.each do |letter|
if letter == "A" || letter == "a"
count = count + 1
end
end
new_array << count
end
p Hash[array.zip(new_array)]
array = ["Alphabet", "aardvark", "anarchy", "purple", "apple", "avalanche", "potato"]
new_array = []
array.each do |name|
find = name.split("")
count = 0
find.each do |letter|
if letter == "A" || letter == "a"
count = count + 1
end
end
new_array << count
end
p Hash[array.zip(new_array)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment