I'm dealing with a function that is supposed to return a JSON object in this format:
this.sampleFunction = (x, filename) => {
if (x.isPresent()) {
return {
'result': true
};
} else {
return {
'result': false 'value': x + "is missing in file" + filename
};
}
}
Additionally, I have another function that invokes the above function:
returnedResult = sampleFunction("saveButton", "AdminPage")
console.log(returnedResult)
console.log(returnedResult.result)
However, both returnedResult
and returnedResult.result
always end up being printed as undefined
. What corrections should I make to ensure the correct JSON output?