Using already created functions inside a new Javascript function

Tags: , ,

I’m beginner, so this question might be silly. I had to do 4 Javascript Function, I will put them below

    function Square(a) {
        return b;

    //2.Functia Half//
    function Half(a) {
        return b;


    //3.Functia Percent//
    function Percent(a,b) {
        return procent + "%";


    //4.Functia Area//
    function Area(a) {
        return final;

Now i have to create the last function, which does:

Applies Half function on the parameter I’ve given to the new function(a), stores is in a new variable(result), result becomes parameter for the function square, the result will be stored again in a new variable(resultSquare), resultSquare will be used in Area function and stored in a new variable(resultArea). In the end, I need percent function, to find out the percent of resultArea from resultSquare. I tried like this, but no luck:

        function new function{
        return result;
        return resultSquare;

It just returns result variable and does nothing else. Can you help? Thank you in advance.


The result exits the function – so anything after a return statement will not be run. You need to return the last item:

function newFunction(a) {
    var result = Half(a);
    var resultSquare = Square(a);
    var resultArea = Area(a);
    return Percent(resultSquare, resultArea);

Source: stackoverflow