title: TypeError: Cannot read properties of undefined (reading 'reduce')
body: <p>If the function is in a component, then everything works fine.
  if I take it out separately and export it to a component, then I get an error <strong>TypeError: Cannot read properties of undefined (reading 'reduce')</strong></p>
  <pre><code>const getAverageScores = (data) =&gt; {
      return data.reduce((acc, {value}) =&gt; acc + value, 0) / data.length;
  </code></pre>
  <p>}</p>
  <p>Help me please</p>
  <pre><code>useEffect(() =&gt; {
      if (data.length) {
           setAverage(getAverageScores(data))
      }
  }, [data])
  </code></pre>
  <p>and I use getAverageScores there</p>
  <pre><code>export  const getStandardDeviation = (data) =&gt; {
  const total = 0;
  const averageScore = getAverageScores()
  const squaredDeviations = data.reduce((total, data) =&gt; {
      const deviation = data &amp;&amp; data.value - averageScore;
      const deviationSquared = deviation * deviation;
  
      return total + deviationSquared;
  }, total);
  
  return Math.sqrt(squaredDeviations / data.length);
  </code></pre>
  <p>}</p>