DEV Community

loading...

Discussion on: PHP 8 features I wish also existed in JavaScript

Collapse
peerreynders profile image
peerreynders

FYI: Often the answer is Use Functions!:

function fontWeight(value) {
  switch (value) {
    case 100:
      return 'Super Thin';
    case 300:
      return 'Thin';
    case 700:
      return 'Bold';
    case 900:
      return 'Heavy';
    default:
      return 'Normal';
  }
}

console.log(fontWeight(700)); // "Bold"
Enter fullscreen mode Exit fullscreen mode