Refactoring functions in Javascript
<p>I am refactoring my javascript code, and now I got a problem that it is not working if I put code in functions while working without using functions, see below:</p>

<p>Not working:</p>

<pre><code>function getFolderPath(){
    var winLocHref =  window.location.href;
    var path = winLocHref.substr(8+document.domain.length);
    var splits=path.split("/");
    path=path.substr(0,path.length-splits[splits.length-1].length);
    path = path.replace(/\//g, '\\\\');
    return path;
}
function getXlsxAbsolutePath(){
    var xslPath = getFolderPath() + "seating_plan_demo.xlsx";
    return xslPath;
}

var excel_file = excel.Workbooks.Open(getXlsxAbsolutePath());
</code></pre>

<p>Working:</p>

<pre><code>var   a   =  window.location.href;
var path = a.substr(8+document.domain.length);
var A=path.split("/");
path=path.substr(0,path.length-A[A.length-1].length);
path = path.replace(/\//g, '\\\\');
xslPath = path + "seating_plan_demo.xlsx";

var excel_file = excel.Workbooks.Open(xslPath);
</code></pre>

<p>Who can tell me what is my problem?</p>

<p>Cheers.</p>
