How to use a return value in another function in Javascript?

前端 未结 6 886
傲寒
傲寒 2020-12-03 02:02

I\'m self-teaching myself JavaScript and out of curiosity I\'m wondering what is the proper way of returning a value from one function to be used in another function. For ex

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 02:32

    You can do this for sure. Have a look below

    function fnOne(){
      // do something
      return value;
    }
    
    
    function fnTwo(){
     var strVal= fnOne();
    //use strValhere   
     alert(strVal);
    }
    

提交回复
热议问题