mardi 3 décembre 2019

JavaScript: how pass edge cases with if else conditions

How I can achieve here with some edge cases that might happen .

//Edge cases If mediaType is undefined it should return undefined or infinity and if mediaType is xs it should return xs with current implementation.

//code current implementation

function getCurrentBreakpoint(mediaType) {
  const mediaTypes = ["xs", "sm", "md", "lg", "xl", "infinity"];
  return mediaTypes[mediaTypes.indexOf(mediaType) - 1];
}

Any help here.

Aucun commentaire:

Enregistrer un commentaire