title: result object returned as undefined when assigned a value
body: <p>I am creating a results object to return a boolean and a string. it is not being reassigned within the if statement. The rest of the code is working correctly and the password gets updated or the right error message is output to the console</p>
  
  <p>i've tried leaving result undefined before the try catch.</p>
  
  <pre><code>async function passwordUpdate(password, currentPassword, newPwd, email) {
    let hashedPassword = await bcrypt.hash(newPwd, 10);
    let result  = { success: false , message: ' '};
  
    try {
      bcrypt.compare(currentPassword, password, async function (err, res) {
        if (res) {
          let updateResult = await updatePwd(hashedPassword, email);
          if (updateResult) {
           result = { success: true , message: 'Password was updated successfully.'}; 
          }
          else {
            logger.info('Password was not updated successfully.');
          }
        } else {
          logger.error('Passwords do not match');
          result= { success: false , message: 'Your current password was entered incorrectly'};
  
          logger.error(result.message);
        }
      });
    } catch (error) {
      result= { success: false , message: 'Failed to compare passwords'}
    }
    logger.error('result ', result.message);
    return result;
  }
  </code></pre>
  
  <p>code is being called by this method</p>
  
  <pre><code>app.post('/passwordUpdate', async (req, res) =&gt; {
    let pwd = req.body.password;
    let cpwd = req.body.currentPwd;
    let newPwd = req.body.newPwd;
    let email = req.body.email;
  
    try {
      let result = await usersModel.passwordUpdate(pwd, cpwd, newPwd, email);
      console.log(result, result.success, result.message);
      if (result.success) {
        res.status(200).json({error: result.message});
      }
      else {
        res.status(404).json({error: result.message});
      }
    } catch (error) {
       console.log(error);
    }
  });
  </code></pre>
  
  <p>logger.error(result.message); this line within the else statement is outputting the message as expected but<br>
  logger.error('result ', result.message); after the try/catch is outputting a blank message for result.message</p>