Skip to content

Commit fcfb3ef

Browse files
Making change for resubmit for PR
1 parent 5cf4592 commit fcfb3ef

4 files changed

Lines changed: 7 additions & 17 deletions

File tree

Sprint-2/implement/contains.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
11
function contains(object, key) {
2-
if (
3-
object === null ||
4-
object === undefined ||
5-
typeof object !== "object" ||
6-
Array.isArray(object)
7-
) {
2+
if (object === null || typeof object !== "object" || Array.isArray(object)) {
83
return false;
94
}
105

116
if (Object.keys(object).length === 0) {
127
return false;
138
}
149

15-
for (const item in object) {
16-
if (Array.isArray(object[item])) {
17-
return false;
18-
}
19-
}
20-
2110
for (const item in object) {
2211
if (item === key) {
2312
return true;
2413
}
2514
}
26-
2715
return false;
2816
}
2917

Sprint-2/implement/contains.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ test("should return false if the input object do not have non existing key value
5151
// Given invalid parameters like an array
5252
// When passed to contains
5353
// Then it should return false or throw an error
54-
test("should return false if the input object do not have non existing key value", () => {
54+
test("should return false if the input parameters is an array or not an object", () => {
5555
let mixObject = { a: 2, b: "hello", c: [] };
56-
expect(contains(mixObject, "c")).toBe(false);
56+
expect(contains(mixObject, "c")).toBe(true);
5757
expect(contains(["A", "B"], "1")).toBe(false);
5858
expect(contains(null, "1")).toBe(false);
5959
expect(contains(undefined, "1")).toBe(false);

Sprint-2/implement/tally.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
function tally(sumArray) {
2-
if (sumArray.length === 0) return {};
32
if (!Array.isArray(sumArray)) {
43
throw new Error("Input musk be an array");
54
}
5+
6+
if (sumArray.length === 0) return {};
7+
68
let totalSum = {};
79
for (const item of sumArray) {
810
if (!Object.hasOwn(totalSum, item)) {

Sprint-3/alarmclock/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<link rel="stylesheet" href="style.css" />
7-
<title>Alarm clock app</title>
7+
<title>Title here</title>
88
</head>
99
<body>
1010
<div class="centre">

0 commit comments

Comments
 (0)