Complete 7

This commit is contained in:
Thuan Bui
2025-02-22 10:53:29 +09:00
parent f8b292fa9f
commit 478676904f
2 changed files with 11 additions and 7 deletions
+6 -2
View File
@@ -1,7 +1,11 @@
const convertToCelsius = function() {
const convertToCelsius = function(degreeinF) {
degreeinC = Math.round(((degreeinF - 32) / 1.8) * 10)/10
return degreeinC
};
const convertToFahrenheit = function() {
const convertToFahrenheit = function(degreeinC) {
degreeinF = Math.round(((degreeinC* 1.8) + 32) * 10)/10
return degreeinF
};
// Do not edit below this line
+5 -5
View File
@@ -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);
});
});