var result = string.split('').forEach(...); Doesn't work in JavaScript : <p>In Javascript, why is result below <code>undefined</code>? </p>

<pre><code>var x = "happy";
var result = x.split('').forEach(function(val,index,array){
   array[index] = "0";
}); 
console.log(result); 
</code></pre>

<p>The output is:</p>

<pre><code>undefined
</code></pre>
