'Set CSS variable with quotes and comma from JavaScript

I have the following CSS:

:root{
  --font-family: "Times", serif;
}

body{
  font-family: var(--font-family);
}

I also have a dropdown with the following values:

serif
sans-serif
'Montserrat', sans-serif;
'Source Code Pro', monospace;

I use this dropdown to set a CSS variable on the body:

let root = document.documentElement;

const fontSelect = document.querySelector("#font")

fontSelect.addEventListener("change", e => {
  console.log(fontSelect.value);
  root.style.setProperty('--font-family', fontSelect.value);
});

Each time, the correct console log happens, however only serif and sans-serif are being applied in Google Chrome. How can I make 'Montserrat', sans-serif; work?

https://codepen.io/EightArmsHQ/pen/3405e40daa7fcc7b17ff8a0e6a205b66



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source