title: Counting the number of times a character appears in an array of strings in Ruby
body: <p>Hi I'm writing a method that needs to check every element in an array for a given character and return the number of times the character appears altogether in the elements of the array.</p>
  
  <p>For creating <code>squarenumbers</code> array I have this code:</p>
  
  <pre><code> squarenumbers = []
   for k in 1..n
     squarenumbers &lt;&lt; k**2
   end
   squarenumbers.map { |a| a.to_s }
   d.to_s
  </code></pre>
  
  <p>And to count the digit so far I have written:</p>
  
  <pre><code>for k in 0..n-1
     count =+1 if squarenumbers[k].include?"d" 
  end 
  </code></pre>
  
  <p>I have created an array of size <code>n</code> containing the square numbers from <code>1 to n</code> and I am now having trouble counting how many times the number <code>d</code> appears in each element.</p>
  
  <p>I converted <code>d</code> to a string in the method and cannot understand why the count is not working. I apologise I'm a beginner but I thought what I've written would check each element in the array for the character d and add 1 to the counter every time a string contains it.</p>
  
  <p>Thanks for all your help.</p>