export default function (string) {
  string = string.toString();
  var value = parseFloat(string, 10);
  var unit = string.slice(-1).toUpperCase();
  if (unit === 'K') {
    value *= 1024;
  } else if (unit === 'M') {
    value *= Math.pow(1024, 2);
  }
  return Math.floor(value);
};

export default function (string) {
  var value, unit;
  string = string.toString();
  value = parseFloat(string, 10);
  unit = string.slice(-1).toUpperCase();
  switch (unit) {
  case 'K':
    value *= 1024;
    break;
  case 'M':
    value *= Math.pow(1024, 2);
    break;
  }
  return Math.floor(value);
};

Replace `if` conditions with `switch/case`