Skip to content

Commit fa54d60

Browse files
authored
Update Convert Fahrenheit to Celsius.js
try and fix the leak
1 parent 21d8802 commit fa54d60

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Parsers/Convert Fahrenheit to Celsius.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ const fahrenheitToCelsius = f => ((f - 32) * 5 / 9).toFixed(2);
99
const formatNumber = num => Number(num).toFixed(2).replace(/\.00$/, '');
1010
const 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

1919
const conversionMessage = conversions.join('\n');
2020

0 commit comments

Comments
 (0)