blob: 8193e77f92310935e681fa12ec6f39f18c3f3a54 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
export const speedConverter = (value, unit) => {
let factor;
switch (unit) {
case 'kmh':
factor = 1.852;
break;
case 'mph':
factor = 1.15078;
break;
case 'kn':
default:
factor = 1;
}
return (value * factor).toFixed(2);
};
export const distanceConverter = (value, unit) => {
let factor;
switch (unit) {
case 'mi':
factor = 0.000621371;
break;
case 'nmi':
factor = 0.000539957;
break;
case 'km':
default:
factor = 0.001;
}
return (value * factor).toFixed(2);
}
|