let positionSettings = require('setting');
function getSetting(element) {
    let setting;
    positionSettings.find({element: element}, function (err,docs) {
        console.log(docs[0].current); // output the value
        setting = docs[0].current;
    });
    return setting;
}
$(document).on("click", "#save" , function(e) {
    console.log(getSetting("abc")); // Output undefined
});
Why is the getSetting() function returning undefined. How can I achieve it.
 
     
    