Skip to content

Commit b9111f1

Browse files
committed
fixed indentation
in querystring file and refactored tally.js to use itemcount
1 parent 1d92cf8 commit b9111f1

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

Sprint-2/implement/querystring.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
function parseQueryString(queryString) {
22
const queryParams = {};
3+
34
if (queryString.length === 0) {
45
return queryParams;
56
}
67

78
if (queryString.includes("&")) {
89
const keyValuePairs = queryString.split("&");
9-
console.log(keyValuePairs + "our 2 pairs");
1010

1111
for (const pair of keyValuePairs) {
1212
if (!pair.includes("=")) {
@@ -36,5 +36,3 @@ function parseQueryString(queryString) {
3636
}
3737

3838
module.exports = parseQueryString;
39-
40-
console.log(parseQueryString("color=brown&width=100"));

Sprint-2/implement/tally.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function tally(inputArray) {
99
let n = 0;
1010

1111
while (inputArray.length > 0) {
12+
itemCount = 0;
1213
const tempArray = [];
1314
let i = 0;
1415
let currentArrayItem = inputArray[0];
@@ -20,11 +21,11 @@ function tally(inputArray) {
2021
i--;
2122
}
2223

23-
i++;
24-
}
24+
if (itemCount > 0) {
25+
tallyObject[currentArrayItem] = itemCount;
26+
}
2527

26-
if (tempArray.length > 0) {
27-
tallyObject[tempArray[0]] = tempArray.length;
28+
i++;
2829
}
2930
}
3031
return tallyObject;

0 commit comments

Comments
 (0)