8000 update answers · M-Munk/javascript-exercises@326ef10 · GitHub
[go: up one dir, main page]

Skip to content

Commit 326ef10

Browse files
committed
update answers
1 parent 180a096 commit 326ef10

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

tempConversion/tempConversion.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
const ftoc = function() {
1+
const ftoc = function (f) {
2+
let c = (f - 32) * (5 / 9);
3+
if (Number.isInteger(c)) {
4+
return c;
5+
} else return parseFloat(c.toFixed(1));
6+
};
27

3-
}
4-
5-
const ctof = function() {
6-
7-
}
8+
const ctof = function (c) {
9+
let f = (c * 9) / 5 + 32;
10+
if (Number.isInteger(f)) {
11+
return f;
12+
} else return parseFloat(f.toFixed(1));
13+
};
814

915
module.exports = {
1016
ftoc,
11-
ctof
12-
}
17+
ctof,
18+
};

tempConversion/tempConversion.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ describe('ftoc', function() {
44
it('works', function() {
55
expect(ftoc(32)).toEqual(0);
66
});
7-
xit('rounds to 1 decimal', function() {
7+
it('rounds to 1 decimal', function() {
88
expect(ftoc(100)).toEqual(37.8);
99
});
10-
xit('works with negatives', function() {
10+
it('works with negatives', function() {
1111
expect(ftoc(-100)).toEqual(-73.3);
1212
});
1313
});
1414

1515
describe('ctof', function() {
16-
xit('works', function() {
16+
it('works', function() {
1717
expect(ctof(0)).toEqual(32);
1818
});
19-
xit('rounds to 1 decimal', function() {
19+
it('rounds to 1 decimal', function() {
2020
expect(ctof(73.2)).toEqual(163.8);
2121
});
22-
xit('works with negatives', function() {
22+
it('works with negatives', function() {
2323
expect(ctof(-10)).toEqual(14);
2424
});
2525
});

0 commit comments

Comments
 (0)
0