(unit)
| 1 | export function unitConversion(unit) { |
| 2 | const u = unit.toLowerCase(); |
| 3 | const grams = ['grams', 'gram', 'g']; |
| 4 | const pounds = ['pounds', 'pound', 'lbs', 'lb']; |
| 5 | const ounces = ['ounces', 'ounce', 'oz', 'o']; |
| 6 | const kilograms = ['kilograms', 'kilogram', 'kg']; |
| 7 | |
| 8 | if (grams.includes(u)) { |
| 9 | return 'g'; |
| 10 | } |
| 11 | |
| 12 | if (pounds.includes(u)) { |
| 13 | return 'lbs'; |
| 14 | } |
| 15 | |
| 16 | if (ounces.includes(u)) { |
| 17 | return 'oz'; |
| 18 | } |
| 19 | |
| 20 | if (kilograms.includes(u)) { |
| 21 | return 'kg'; |
| 22 | } |
| 23 | |
| 24 | return null; |
| 25 | } |