How to and an extra value to return from function?

I’m hoping my problem is going to be another “Doh!” experience. I’ve written a backend function to retrieve the current member details and if the member holds a certain badge. It should be so straightforward to an extra field to returned object but I just can’t figure out the correct format!
It’s line 8 and I’ve currently got member [ ‘permission’ ]= checkBadge ([ member . _id ,]);
but it isn’t working.
Can anyone explain what I’m doing wrong?

Thanks

export function getCurrentMember ( ) {
let options = {
fieldsets : [ ‘FULL’ ],
}

return currentMember . getMember ( options )
. then (( member ) => {
member [ ‘permission’ ]= checkBadge ([ member . _id ,]);
return member ;
})
. catch (( error ) => {
console . error ( error );
})
}

function checkBadge ( members ) {
let matchesBadge = false ;
return badges . listMemberBadges ( members )
. then (( allBadges ) => {
if ( allBadges . length > 0 ) {
matchesBadge =( allBadges [ 0 ]. badgeIds . find ( matchBadge ) !== “undefined” );
}
return matchesBadge ;
})
. catch (( error ) => {
console . error ( error );
})
}

function matchBadge ( badge ) {
const badgeId = ‘f269cc69-9362-4736-aed2-78841ba33c52’ ;
return badge == badgeId ;
}

Do you want to return both the full member and bandages? then:

//getCurrentMember function:
  //...
return currentMember.getMember(options)
  .then((member) => {
    return checkBadge(member);
  })
  //...checkBadge function:
  function checkBadge(member) {
  return badges.listMemberBadges([member._id])
    .then(allBadges => {
    member.badgeIds = [];
    if(allBadges.length > 0){
      member.badgeIds = allBadges[0].badgeIds;
    } 
   return member;
  // it'll return the full member object including badgeIds field
  }

Funny isn’t it. You simply can’t see the solution and then with just a little help clarity is achieved!
Thanks very much for your help.
Doug

You’re welcome (I made a small change). Check if it works for you.