Skip to content

Commit 4c519d9

Browse files
committed
Update proof solution
1 parent 286fbd2 commit 4c519d9

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

exercises/practice/resistor-color-trio/.meta/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"SleeplessByte"
44
],
55
"contributors": [
6-
"hayashi-ay"
6+
"hayashi-ay",
7+
"jagdish-15"
78
],
89
"files": {
910
"solution": [

exercises/practice/resistor-color-trio/.meta/proof.ci.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const COLORS = [
1212
];
1313

1414
const ONE_KILOOHM = 1000;
15+
const ONE_MEGAOHM = 1000000;
16+
const ONE_GIGAOHM = 1000000000;
1517

1618
class ArgumentError extends Error {}
1719

@@ -44,9 +46,18 @@ export class ResistorColorTrio {
4446

4547
toString() {
4648
const value = this.value;
47-
return value < ONE_KILOOHM
48-
? `${value} ohms`
49-
: `${Math.floor(value / ONE_KILOOHM)} kiloohms`;
49+
50+
if (value >= ONE_GIGAOHM) {
51+
return `${Math.floor(value / ONE_GIGAOHM) } gigaohms`;
52+
}
53+
if (value >= ONE_MEGAOHM) {
54+
return `${Math.floor(value / ONE_MEGAOHM) } megaohms`;
55+
}
56+
if (value >= ONE_KILOOHM) {
57+
return `${Math.floor(value / ONE_KILOOHM) } kiloohms`;
58+
}
59+
60+
return `${value} ohms`;
5061
}
5162

5263
/**

0 commit comments

Comments
 (0)