I load a javascript file asynchronously and the file contains this line defined within a plugin defaults. It returns correct return value in some pages whereas in other pages the same file returns 'undefined' values. Any pointers?
login: '<p>Log in with your '+ fnc(code).name +' account</p>'
somewhere at the bottom of the same file I have defined the function:
function fnc(s){
if(s =='' || s == 'a'){
this.name = 'name1';
this.value = 'value1';
}else if(s == 'b'){
this.name = 'name2';
this.value = 'value2';
}else{
this.name = 'name1';
this.value = 'value1';
}
return this;
}
For some reason, the function returns 'undefined'
UPDATE: "code" is a global variable that is present in some other file, depending on the value of that variable, I want to return different values from the function
UPDATE2: I want to return multiple values from the function, updated the code to reflect that.