File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -9,12 +9,12 @@ const fahrenheitToCelsius = f => ((f - 32) * 5 / 9).toFixed(2);
99const formatNumber = num => Number ( num ) . toFixed ( 2 ) . replace ( / \. 0 0 $ / , '' ) ;
1010const conversions = [ ] ;
1111
12- current . text = current . text . replace ( regexTest , ( match , f ) => {
13- const celsius = fahrenheitToCelsius ( f ) ;
14- const formattedF = formatNumber ( f ) ;
15- conversions . push ( ` ${ formattedF } °F is ${ celsius } degrees in sane units (Celsius).` ) ;
16- return `${ celsius } °C` ;
17- } ) ;
12+ let match ;
13+ while ( ( match = regexTest . exec ( current . text ) ) !== null ) {
14+ const fahrenheit = parseFloat ( match ) ;
15+ const celsius = fahrenheitToCelsius ( fahrenheit ) ;
16+ conversions . push ( `${ formatNumber ( fahrenheit ) } °F is ${ formatNumber ( celsius ) } degrees in sane units (Celsius).` ) ;
17+ }
1818
1919const conversionMessage = conversions . join ( '\n' ) ;
2020
You can’t perform that action at this time.
0 commit comments