Skip to content

Commit

Permalink
Fix typo in celsius to fahre and pass all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
worriedape committed Dec 10, 2024
1 parent 57d134f commit 5ff73d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions 07_tempConversion/tempConversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ const convertToCelsius = function(fahre) {

let convert = ((fahre - 32) * 5/9);

return convert.toFixed(1)
//return convert.toFixed(1)

return Math.round(convert * 10) / 10;
};

const convertToFahrenheit = function(celsius) {

let convert = ((celsius - 32) * 9 / 5);

return convert.toFixed(1);
let convert = ((celsius * 9/5) + 32);

//return convert.toFixed(1);
return Math.round(convert * 10) / 10;
};

// Do not edit below this line
Expand Down
10 changes: 5 additions & 5 deletions 07_tempConversion/tempConversion.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ 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);
});
});

describe('convertToFahrenheit', () => {
test.skip('works', () => {
test('works', () => {
expect(convertToFahrenheit(0)).toEqual(32);
});
test.skip('rounds to 1 decimal', () => {
test('rounds to 1 decimal', () => {
expect(convertToFahrenheit(73.2)).toEqual(163.8);
});
test.skip('works with negatives', () => {
test('works with negatives', () => {
expect(convertToFahrenheit(-10)).toEqual(14);
});
});

0 comments on commit 5ff73d5

Please sign in to comment.