Skip to content

Commit

Permalink
Update Convert Fahrenheit to Celsius.js
Browse files Browse the repository at this point in the history
try and fix the leak
  • Loading branch information
chelming authored Feb 5, 2025
1 parent 21d8802 commit fa54d60
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Parsers/Convert Fahrenheit to Celsius.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ const fahrenheitToCelsius = f => ((f - 32) * 5 / 9).toFixed(2);
const formatNumber = num => Number(num).toFixed(2).replace(/\.00$/, '');
const conversions = [];

current.text = current.text.replace(regexTest, (match, f) => {
const celsius = fahrenheitToCelsius(f);
const formattedF = formatNumber(f);
conversions.push(`${formattedF}°F is ${celsius} degrees in sane units (Celsius).`);
return `${celsius}°C`;
});
let match;
while ((match = regexTest.exec(current.text)) !== null) {
const fahrenheit = parseFloat(match);
const celsius = fahrenheitToCelsius(fahrenheit);
conversions.push(`${formatNumber(fahrenheit)}°F is ${formatNumber(celsius)} degrees in sane units (Celsius).`);
}

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

Expand Down

0 comments on commit fa54d60

Please sign in to comment.