Skip to content

Commit 33d17a2

Browse files
Formatting all the file in sprint 2
1 parent 9251977 commit 33d17a2

8 files changed

Lines changed: 45 additions & 46 deletions

File tree

Sprint-2/implement/contains.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ function contains(object, key) {
33
return false;
44
}
55

6-
for (const checkItem in object){
7-
let validation = object[checkItem]
8-
if(Array.isArray(validation)){
6+
for (const checkItem in object) {
7+
let validation = object[checkItem];
8+
if (Array.isArray(validation)) {
99
return false;
10-
}
10+
}
1111
}
1212
for (const item in object) {
1313
if (item === key) {
1414
return true;
1515
}
1616
}
17-
return false;
17+
return false;
1818
}
1919

2020
module.exports = contains;

Sprint-2/implement/contains.test.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,41 @@ as the object doesn't contains a key of 'c'
1717
// When passed an object and a property name
1818
// Then it should return true if the object contains the property, false otherwise
1919
test("should return true if the input object contain the key value", () => {
20-
expect(contains({a:1,b:2,c:3,d:4},"a")).toBe(true);
21-
expect(contains({a:1,b:2,c:3,d:4},"f")).toBe(false);
20+
expect(contains({ a: 1, b: 2, c: 3, d: 4 }, "a")).toBe(true);
21+
expect(contains({ a: 1, b: 2, c: 3, d: 4 }, "f")).toBe(false);
2222
});
2323

2424
// Given an empty object
2525
// When passed to contains
2626
// Then it should return false
2727
test("should return false if the object is empty", () => {
2828
let emptyObject = {};
29-
expect(contains(emptyObject,"a")).toBe(false);
29+
expect(contains(emptyObject, "a")).toBe(false);
3030
});
3131

3232
// Given an object with properties
3333
// When passed to contains with an existing property name
3434
// Then it should return true
3535
test("should return true if the input object contain existing key value", () => {
36-
let infoObject = {name:"John",age:"24",city:"Glasgow"};
37-
expect(contains(infoObject,"name")).toBe(true);
38-
expect(contains(infoObject,"age")).toBe(true);
39-
expect(contains(infoObject,"city")).toBe(true);
36+
let infoObject = { name: "John", age: "24", city: "Glasgow" };
37+
expect(contains(infoObject, "name")).toBe(true);
38+
expect(contains(infoObject, "age")).toBe(true);
39+
expect(contains(infoObject, "city")).toBe(true);
4040
});
4141

4242
// Given an object with properties
4343
// When passed to contains with a non-existent property name
4444
// Then it should return false
4545
test("should return false if the input object do not have non existing key value", () => {
46-
let goodsObject = {fruit:"Apple",amount:"50",origin:"Glasgow"};
47-
expect(contains(goodsObject,"tree")).toBe(false);
48-
expect(contains(goodsObject,"color")).toBe(false);
49-
expect(contains(goodsObject,"country")).toBe(false);
46+
let goodsObject = { fruit: "Apple", amount: "50", origin: "Glasgow" };
47+
expect(contains(goodsObject, "tree")).toBe(false);
48+
expect(contains(goodsObject, "color")).toBe(false);
49+
expect(contains(goodsObject, "country")).toBe(false);
5050
});
5151
// Given invalid parameters like an array
5252
// When passed to contains
5353
// Then it should return false or throw an error
5454
test("should return false if the input object do not have non existing key value", () => {
55-
let mixObject = {a:2,b:"hello",c:[]};
56-
expect(contains(mixObject,"c")).toBe(false);
57-
});
55+
let mixObject = { a: 2, b: "hello", c: [] };
56+
expect(contains(mixObject, "c")).toBe(false);
57+
});

Sprint-2/implement/lookup.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
function createLookup(pairs) {
22
// implementation here
33
let countryPair = {};
4-
for (const [country, currency] of pairs) {
5-
countryPair[country] = currency;
6-
}
4+
for (const [country, currency] of pairs) {
5+
countryPair[country] = currency;
6+
}
77

8-
return countryPair;
8+
return countryPair;
99
}
1010

1111
module.exports = createLookup;
12-

Sprint-2/implement/lookup.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ const createLookup = require("./lookup.js");
22

33
test("creates a country currency code in an lookup array for multiple codes, and return in object form", () => {
44
let worldCurrency = [
5-
["US","USD"],
6-
["GB","POUND"],
7-
["FRC","EURO"],
8-
["JP","YEN"],
9-
["KR","WON"],
10-
["MX","PESO"],
5+
["US", "USD"],
6+
["GB", "POUND"],
7+
["FRC", "EURO"],
8+
["JP", "YEN"],
9+
["KR", "WON"],
10+
["MX", "PESO"],
1111
];
1212
expect(createLookup(worldCurrency)).toEqual({
1313
US: "USD",

Sprint-2/implement/querystring.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// Below is one test case for an edge case the implementation doesn't handle well.
44
// Fix the implementation for this test, and try to think of as many other edge cases as possible - write tests and fix those too.
55

6-
const parseQueryString = require("./querystring.js")
6+
const parseQueryString = require("./querystring.js");
77

88
test("parses querystring values containing =", () => {
99
expect(parseQueryString("equation=x=y+1")).toEqual({
10-
"equation": "x=y+1",
10+
equation: "x=y+1",
1111
});
1212
});

Sprint-2/implement/tally.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function tally(sumArray) {
2-
if (sumArray.length === 0) return {} ;
3-
if (!Array.isArray(sumArray)){
4-
throw new Error("Input musk be an array")
2+
if (sumArray.length === 0) return {};
3+
if (!Array.isArray(sumArray)) {
4+
throw new Error("Input musk be an array");
55
}
66
let totalSum = {};
77
for (const item of sumArray) {

Sprint-2/implement/tally.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ const tally = require("./tally.js");
2323
// Given an empty array
2424
// When passed to tally
2525
// Then it should return an empty object
26-
test("tally on an empty array returns an empty object",() =>{
27-
let emptyObject =[];
28-
expect(tally(emptyObject)).toEqual({});
26+
test("tally on an empty array returns an empty object", () => {
27+
let emptyObject = [];
28+
expect(tally(emptyObject)).toEqual({});
2929
});
3030

3131
// Given an array with duplicate items
3232
// When passed to tally
3333
// Then it should return counts for each unique item
34-
test("tally on an array with duplicate returns with correct amount object",() =>{
35-
let firstObject =["a","a","c","b","c","b","a","c",];
36-
expect(tally(firstObject)).toEqual({a:3,b:2,c:3});
34+
test("tally on an array with duplicate returns with correct amount object", () => {
35+
let firstObject = ["a", "a", "c", "b", "c", "b", "a", "c"];
36+
expect(tally(firstObject)).toEqual({ a: 3, b: 2, c: 3 });
3737
});
3838
// Given an invalid input like a string
3939
// When passed to tally
4040
// Then it should throw an error
41-
test("tally on a string should throw invalid input",() =>{
42-
let stringInput = "input";
43-
expect(() => tally(stringInput)).toThrow("Input musk be an array");
44-
});
41+
test("tally on a string should throw invalid input", () => {
42+
let stringInput = "input";
43+
expect(() => tally(stringInput)).toThrow("Input musk be an array");
44+
});

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>Title here</title>
7+
<title>Alarm clock app</title>
88
</head>
99
<body>
1010
<div class="centre">

0 commit comments

Comments
 (0)