Functional Programming issue regarding passing functions with parameters in Javascript
<p>I am currently writing an API to unzip files to the web browser sandbox filesystem. I have a basic need to pass a parameter to a function that in turn is it'self passed as a parameter. Here is some code to illustrate the issue:</p>

<pre><code>//Request a permanent filesystem quota to unzip the catalog.
function requestFilesystem(size){
    window.webkitStorageInfo.requestQuota(PERSISTENT, size*1024*1024, function(grantedBytes) {
        window.requestFileSystem(PERSISTENT, grantedBytes, function(fs) {
            filesystem = fs;
            removeRecursively(filesystem.root, unzip(url), onerror);
        }, onerror);
    }, function(e) {
        console.log('Error', e);
    });
}

//unzip method can be changed, API remains the same.
//URL of zip file
//callback oncomplete
function unzip(URL) {
    importZipToFilesystem(URL, function(){
        console.log("Importing Zip - Complete!");
    });
}

//remove removeRecursively a folder from the FS
function removeRecursively(entry, onend, onerror) {
    var rootReader = entry.createReader();
    console.log("Remove Recursive"+entry.fullPath);
    rootReader.readEntries(function(entries) {
        var i = 0;

        function next() {
            i++;
            removeNextEntry();
        }

        function removeNextEntry() {
            var entry = entries[i];
            if (entry) {
                if (entry.isDirectory)
                    removeRecursively(entry, next, onerror);
                if (entry.isFile)
                    entry.remove(next, onerror);
            } else
                onend();
**Uncaught TypeError: undefined is not a function**
        }

        removeNextEntry();
    }, onerror);
}
</code></pre>

<p>If I try to use </p>

<pre><code>function removeRecursively(entry, onend(URL), onerror) { 
</code></pre>

<p>there is an error, ao my issue is how to pass around the URL value for the unzip function, this unzip function is used as a callback function on the onsuccess of removeRecursively</p>
