Return string from function - Javascript Function

Javascript examples for Function:Function Return

Description

Return string from function

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <script>
var someVariable = "this is test";
function alertSomething() {/*  w  w w  .  j a v a 2 s  . c  o  m*/
  console.log(someVariable);
}
function returnSomething(){
  return someVariable;
}
var a = alertSomething();
var b = returnSomething();
console.log("the alert method doesn't return a value: " + a);
console.log("return: " + b);

      </script>  
   </body>
</html>

Related Tutorials