How to return a value from that function in JavaScript

3 Answers

0 votes
function myFunction() { 

    var a = 3, b = 10;
    
    return a + b;
}
 
document.write(myFunction()); 

 
/*
run:

13 

*/

 



answered Apr 30, 2017 by avibootz
0 votes
function myFunction(a, b) { 

    return a + b;
}
 
document.write(myFunction(3, 10)); 

 
/*
run:

13 

*/

 



answered Apr 30, 2017 by avibootz
0 votes
function myFunction(profession) { 

    return "tom is a " + profession;
}
 
document.write(myFunction("programmer")); 

 
/*
run:

tom is a programmer 

*/

 



answered May 1, 2017 by avibootz
...