I have the following code:
let tasks;
try {
await checkMongoConnection();
const tasks = await Task
.find()
await disconnectMongo();
if (!tasks) { return reject(); }
// Is is possible to use the same naming?
tasks = tasks;
} catch(error) {
console.log(error.message);
}
In JS is it possible to use the same naming like this? e.g. tasks = tasks
and set the variable outside the try
block or do I have to use a new name e.g. tasks = fetchedTasks
?