I'm using the getComputedStyles
function to get the styles of a certain text element on a page. Whenever I try to get the font family, instead of getting a single font family name, I get multiple ones, especially the generic ones like Helvetica, SegoeUI, Noto, etc..
How can I get it to show me only the first font family?
I've tried using .slice
and fontFamily[0]
but that only gets me the first letter not the first element
Code
const getStyles = getComputedStyle(textElement);
const family = getStyles.fontFamily;
const newFont = family;
console.log(newFont);