How to update metadata using javascript?

Thank you for replying!! I’m assuming this goes into the js file right? Although it doesn’t seem to work for me, so I think I might be doing something wrong. The script as it is right now below:

// this was the initial function: to play music when the button was clicked
// audio url was pulled from the "src" value when the audio was embedded into the file
var audio = new Audio('audio/url.mp3');
audio.play();

// property key is "completed", a checkbox property, it is false by default
// the button should switch it to true
app.fileManager.processFrontMatter(file, frontmatter => {
    frontmatter['completed'] = true;
  })

For curiosity’s sake I also stuck the frontmatter code into the metabind button, but that gave an error, understandably