Skip to content

Commit 96d1d84

Browse files
committed
Corrected Code Format and Declarations Const/ Lets
1 parent 9285ca4 commit 96d1d84

File tree

6 files changed

+15
-20
lines changed

6 files changed

+15
-20
lines changed

Sprint-1/implement/dedupe.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function dedupe(arr) {
2-
let result = [];
3-
for (let item of arr) {
2+
const result = [];
3+
for (const item of arr) {
44
if (!result.includes(item)) {
55
result.push(item);
66
}

Sprint-1/implement/dedupe.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test("dedupe an empty array returns an empty array", () =>{
2525
// Given an array with no duplicates
2626
// When passed to the dedupe function
2727
// Then it should return a copy of the original array
28-
test(" Given an array with no duplicates", () => {
28+
test("Given an array with no duplicates", () => {
2929
const inputNoDuplicates = ["a", "b", "c" ];
3030
const result = dedupe(inputNoDuplicates);
3131
expect(result).toEqual(["a", "b", "c"]);

Sprint-1/implement/max.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function findMax(numbersList) {
2-
let onlyNumbers = numbersList.filter((item) => typeof item === "number");
3-
let currentMax = Math.max(...onlyNumbers); ;
2+
let onlyNumbers = numbersList.filter((item) => typeof item === "number");
3+
let currentMax = Math.max(...onlyNumbers);
44
return currentMax;
55
}
66

Sprint-1/implement/sum.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
function sum(theArray) {
2-
3-
let onyNumbers = theArray.filter(item => typeof item === 'number');
4-
5-
6-
const theFinalSum = onyNumbers.reduce((runningTotal, currentNumber) => {
2+
const onlyNumbers = theArray.filter((item) => typeof item === "number");
3+
const theFinalSum = onlyNumbers.reduce((runningTotal, currentNumber) => {
74
return runningTotal + currentNumber;
85
}, 0);
9-
106
return theFinalSum;
117
}
128

13-
console.log (sum(["hey", 10, "hi", 60, 10]));
9+
console.log(sum(["hey", 10, "hi", 60, 10]));
1410

1511
module.exports = sum;
1612

Sprint-1/implement/sum.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ test("given an empty array, returns 0", () => {
2323
// When passed to the sum function
2424
// Then it should return that number
2525

26-
test("given an array with 1 number, it returns the sam number", () => {
26+
test("given an array with 1 number, it returns the sum number", () => {
2727
const inputNumber = [34];
2828
const result = sum(inputNumber);
2929
expect(result).toEqual(34);

Sprint-1/refactor/includes.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
// return false;
1111
// }
1212

13-
14-
function includes(list,target){
15-
for (let value of list) {
16-
if (value === target) {
17-
return true;
13+
function includes(list, target) {
14+
for (const value of list) {
15+
if (value === target) {
16+
return true;
17+
}
1818
}
19+
return false;
1920
}
20-
return false;
21-
};
2221

2322
module.exports = includes;

0 commit comments

Comments
 (0)