Q:

How to get text inside one span tag to another span tag?

Need to get the value 40.78 from <span> to be stored in <span id ="test">. 
Tried the code below. But not able to figure out what's going wrong. The error  getting on console is :

Uncaught ReferenceError: div is not defined.

Any help would be really appreciated.

var span = div.getElementsByTagName("span");
var test = document.getElementById('test');
console.log(test.innerHTML = span.innerHTML);
<span>40.78</span>
<span id="test"></span>

A:

div is not defined any where in the code. Use document instead.
getElementsByTagName() returns collection, you have to use index. I will also suggest you to use textContent instead of innerHTML when dealing with text only content:

<html>
  <body>
   <div>
    <span>40.78</span>
   </div>
    <span id = "test"></span>
     <script>
      var span = document.getElementsByTagName("span")[0];
      var test = document.getElementById( 'test' );
      test.textContent = span.textContent;
      console.log(test.textContent);
     </script>
 </body>
</html>

