You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/concept/recycling-robot/.docs/instructions.md
+31-22Lines changed: 31 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,8 @@ isObject(25n);
52
52
53
53
### 4. Check if a string is numeric
54
54
55
-
Implement the `isNumericString` function, that should check if the value is a string that only consists of digits.
55
+
Implement the `isNumericString` function, that should check if the value is a string that only consists of digits or a minus followed by digits indicating a negative number.
56
+
Only integers should be considered, decimals are not considered numeric for this check of the recycling robot.
56
57
57
58
```javascript
58
59
isNumericString(42);
@@ -109,21 +110,7 @@ isEmptyArray([]);
109
110
// => true
110
111
```
111
112
112
-
### 8. Throw an error if an object does not have an `id` property or method
113
-
114
-
Implement the `assertHasId` function, that will throw an `Error` if an object is missing the `id` property.
115
-
116
-
If an object does have the `id` property, it should not return anything.
117
-
118
-
```javascript
119
-
assertHasId({ id:42, color:'red' });
120
-
// => undefined
121
-
122
-
assertHasId({ color:'green' });
123
-
// Error: "Object is missing the 'id' property"
124
-
```
125
-
126
-
### 9. Check if an object has a `type` property or method
113
+
### 8. Check if an object has a `type` property or method
127
114
128
115
Implement the `hasType` function, that checks whether an object has a `type` property or method.
129
116
@@ -133,40 +120,62 @@ class Keyboard(){
133
120
// ...
134
121
}
135
122
}
136
-
hasType({type:"car",color:"red"})
123
+
hasType({type:"car",color:"red"})
137
124
// => true
138
125
139
-
hasType({color:"green"})
126
+
hasType({color:"green"})
140
127
// => false
141
128
142
129
hasType(newKeyboard())
143
130
// => true
144
131
```
145
132
133
+
### 9. Throw an error if an object does not have an `id` property or method
134
+
135
+
Implement the `assertHasId` function, that will throw an `Error` if an object is missing the `id` property.
136
+
137
+
If an object does have the `id` property, it should not return anything.
138
+
139
+
```javascript
140
+
assertHasId({ id:42, color:'red' });
141
+
// => undefined
142
+
143
+
assertHasId({ color:'green' });
144
+
// Error: "Object is missing the 'id' property"
145
+
```
146
+
146
147
### 10. Check if an object has an `id` property
147
148
148
149
Implement the `hasIdProperty` function, that checks whether an object has an `id` property.
0 commit comments