Do I have my Ends commented right?

“Write a method count_a(word) that takes in a string word and returns the number of a’s in the word. The method should count both lowercase (a) and uppercase (A)”

def count_a(word)
a_count = 0

i = 0
while i < word.length
char = word[i]

if char == "a" || char == "A"
  a_count += 1
end # if - **am I right?**
i += 1
end # while - **am I right?**

return a_count
end # count - am I right?

puts count_a(“application”) # => 2
puts count_a(“bike”) # => 0
puts count_a(“Arthur”) # => 1
puts count_a(“Aardvark”) # => 3

Yes! Think of ‘end’ as a circuit breaker that demarcates sub-domains of code or halts some iterative (repetitive) functionality and allows the coding process to stop where otherwise it would continue (example: putting “end” at the end of an if-conditional tells the process to stop once a character has been evaluated, and thus defines if- conditional functionality as including only char == “a” || char ==“A” evaluation and a_count +=1 output.