JSFiddle - React, Tailwind, and code Playground

HTML

<div id='result'></div>

JavaScript

function compose(f,g){
    return function(x){
        return g(f(x));
    };
}

function double(x){
    return 2*x;
}

function square(x){
    return x*x;
}

var doubleSquare = compose(square,double);
    
$('#result').html("Calculating...");
$('#result').html(doubleSquare(3));