title: JavaScript Functions , return undefined
body: <p><strong>Hello Everyone hope you all doing great ,</strong></p>
  
  <p>this is my code , function with name and callback 
  taking the name to callback function to make return the name and console.log it</p>
  
  <p>if i </p>
  
  <pre><code>function doSomething(name,callback) {
      callback(name);
  }
  
  function foo(n) {
      return n;
  }
  
  var val = doSomething("TEST",foo);
  console.log(val);
  </code></pre>
  
  <p>i got undefined .</p>
  
  <p>if i </p>
  
  <pre><code>function doSomething(name,callback) {
      callback(name);
  }
  
  function foo(n) {
      console.log(n);
  }
  
  var val = doSomething("TEST",foo);
  </code></pre>
  
  <p>that works fine and console.log the TEST name .</p>
  
  <p>So why the return not working ?</p>
  
  <p>thanks</p>