1. Convert figures to percentages

export function toPercent(point) {
  if (point === 0) {
    return0; } // var str = Number(point*100); Var STR = Number(parseFloat((point * 100).toprecision (12))); str = Number.isInteger(str) ? str.toFixed() : str.toFixed(1); str +=The '%';
  return str;
}
Copy the code

2. Reverse the key and value of the object

export function invertKeyValues(obj) {
  return Object.keys(obj).reduce((acc, key) => {
    acc[obj[key]] = key;
    return acc;
  }, {});
}

Copy the code

Continuously updated…