Roohollah
Roohollah

Reputation: 69

using output of a function as a string variable

I want to use output of my function as a string variable.

I have this function:

schemaTitle: function() {
    return Categories.findOne({_id: "Gt5prgS4RW3GW23NG"}).title;
}

now I want to use output of above return like a string variable, somewhere like this:

switch(this.schemaTitle) {
    case "HOME":
        return {
            schemaName: "StateSchema"
        };
        break; 
}

how can I do this?

Upvotes: 1

Views: 48

Answers (1)

crackmigg
crackmigg

Reputation: 5881

You are not invoking the function schemaTitle, only referencing it. Just replace

switch(this.schemaTitle) {

with

switch(this.schemaTitle()) {

to invoke the function and use its return value.

Upvotes: 4

Related Questions