Passed tests 2 & 3 toCelsius from exercise 07

added Math.round

essentially multiplying inside of round, and dividing out of it will increase the rounding decimal point
This commit is contained in:
NetMan 2024-01-05 22:06:28 +01:00
parent 46732dbe89
commit 08d14383b0
2 changed files with 3 additions and 3 deletions

View File

@ -1,5 +1,5 @@
const convertToCelsius = function(deg) {
return (deg - 32) * (5/9);
return Math.round((deg - 32) * (5/9) * 10) / 10;
};
const convertToFahrenheit = function() {

View File

@ -4,10 +4,10 @@ describe('convertToCelsius', () => {
test('works', () => {
expect(convertToCelsius(32)).toEqual(0);
});
test.skip('rounds to 1 decimal', () => {
test('rounds to 1 decimal', () => {
expect(convertToCelsius(100)).toEqual(37.8);
});
test.skip('works with negatives', () => {
test('works with negatives', () => {
expect(convertToCelsius(-100)).toEqual(-73.3);
});
});