In the following code, I want to assign the value of varOne to varTwo, however the assignment operator is executing before the properties.parse function. I'm unable to figure out why this is happening. I've tried to put properties.parse in a function, and assignment variable with return statement. But it is not working.
var properties = require ("properties")
// create two variables, varOne will be assigned to varTwo.
// I want varOne to be assigned in the properties.parse block
var varOne;
var varTwo;
properties.parse("sample.conf", { path: true, namespaces: true }, function (error, obj){
if (error) return console.error (error);
console.log("varOne is: " + obj.config.harsh);
varOne = obj.config.harsh;
//{ a: 1, b: 2, b: 3 }
});
// The following code is getting executed before the above properties.parse block. I need this code to execute after the above block.
varTwo = varOne;
console.log("varTwo is: " + varTwo);
// Result:
// varTwo is: undefined
// varOne is: "10.0.3.183"