Q:

How to create function that reproduces other functions

This is a very basic exercise, but I cannot seem to find a way to reproduce a couple of functions inside of a function. 

landscape(nf,sf,nm,sm) receives number of flats, size of flats, number of mountains, size of mountains. 
flat(sf) - reproduces a set of sf number of underscores (_)
mountain(sm) - reproduces a set of sm number of ', between /\
times(nf,nm) - is supposed to reproduce nf and nm number of flats and mountains. 

But times doesn't seem to be working.  What am I doing wrong? 

var landscape = function (nf, sf, nm, sm) {
    var result = "";
    var flat = function(sf) {
        for (var x = 0; x < sf; x++) {
            result += "_";
        }
    }
    
    var mountain = function(sm) {
        result += "/";
        for(var x = 0; x < sm; x++) {
            result += "'";
        }
        result += "\\";
    }
    

    var times = function(nf, nm) {
    // executes flat(nf) and mountain(sm)
        for (var z = 0; z < nf; z++) {
            flat(sf);
            for (var y = 0; y < nm; y++) {
                mountain(sm);
            }
        }
    }
    
    return result;
}

console.log(landscape(2,3,2,3));

A:

You create the times function but you return result; before you execute it.  
Add times(nf, nm); in before returning

