App Academy

Counting characters in a string using loops in ruby

I am new to programming. so this is my very first time to code. My journey through App Academy’s curriculum has been so great until I got stuck into this loops exercise. The question is the following:
Write a method count_e(word) that takes in a string word and returns the number of e’s in the word. it can be seen on the screenshot provided below. and the solution is included to the right hand side. but I do not grasp the meaning behind that solution. I attempted to go through the exercise walkthrough video but I still don’t really get the reasonning behind it. would anyone help comment on that solution?