8000 remove class based exercises · Dreniak/javascript-exercises@290e7f1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 290e7f1

Browse files
committed
remove class based exercises
1 parent f0bf584 commit 290e7f1

File tree

18 files changed

+67
-164
lines changed

18 files changed

+67
-164
lines changed

book_titles/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

book_titles/bookTitles.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

book_titles/bookTitles.spec.js

Lines changed: 0 additions & 64 deletions
This file was deleted.

helloWorld/helloWorld.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var helloWorld = function() {
2-
return ''
2+
return 'Hello, World!'
33
}
44

5-
module.exports = helloWorld
5+
module.exports = helloWorld

leapYears/leapYears.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
var leapYears = function() {
2-
1+
var leapYears = function(year) {
2+
if (year % 4 !== 0 || (year % 100 == 0 && year % 400 != 0)) {
3+
return false
4+
}
5+
return true
36
}
47

58
module.exports = leapYears

leapYears/leapYears.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ describe('leapYears', function() {
44
it('works with non century years', function() {
55
expect(leapYears(1996)).toEqual(true);
66
});
7-
xit('works with non century years', function() {
7+
it('works with non century years', function() {
88
expect(leapYears(1997)).toEqual(false);
99
});
10-
xit('works with ridiculously futuristic non century years', function() {
10+
it('works with ridiculously futuristic non century years', function() {
1111
expect(leapYears(34992)).toEqual(true);
1212
});
13-
xit('works with century years', function() {
13+
it('works with century years', function() {
1414
expect(leapYears(1900)).toEqual(false);
1515
});
16-
xit('works with century years', function() {
16+
it('works with century years', function() {
1717
expect(leapYears(1600)).toEqual(true);
1818
});
19-
xit('works with century years', function() {
19+
it('works with century years', function() {
2020
expect(leapYears(700)).toEqual(false);
2121
});
2222
});

removeFromArray/removeFromArray.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
var removeFromArray = function() {
2-
1+
var removeFromArray = function(array) {
2+
elementsToRemove = [...arguments]
3+
elementsToRemove.splice(0,1)
4+
elementsToRemove.forEach(element => {
5+
let index = array.indexOf(element)
6+
if (index > -1) {
7+
array.splice(index, 1)
8+
}
9+
})
10+
return array
311
}
412

513
module.exports = removeFromArray

removeFromArray/removeFromArray.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ describe('removeFromArray', function() {
44
it('removes a single value', function() {
55
expect(removeFromArray([1, 2, 3, 4], 3)).toEqual([1, 2, 4]);
66
});
7-
xit('removes multiple values', function() {
7+
it('removes multiple values', function() {
88
expect(removeFromArray([1, 2, 3, 4], 3, 2)).toEqual([1, 4]);
99
});
10-
xit('ignores non present values', function() {
10+
it('ignores non present values', function() {
1111
expect(removeFromArray([1, 2, 3, 4], 7, "tacos")).toEqual([1, 2, 3, 4]);
1212
});
13-
xit('ignores non present values, but still works', function() {
13+
it('ignores non present values, but still works', function() {
1414
expect(removeFromArray([1, 2, 3, 4], 7, 2)).toEqual([1, 3, 4]);
1515
});
16-
xit('can remove all values', function() {
16+
it('can remove all values', function() {
1717
expect(removeFromArray([1, 2, 3, 4], 1, 2, 3, 4)).toEqual([]);
1818
});
19-
xit('works with strings', function() {
19+
it('works with strings', function() {
2020
expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toEqual([2, "ho"]);
2121
});
2222
});

repeatString/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Exercise 02 - repeatString
1+
# Exercis 02 - repeatString
22

33
Write a function that simply repeats the string a given number of times:
44

repeatString/repeatString.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
var repeatString = function() {
2-
1+
var repeatString = function(string, num) {
2+
if (num < 0) return 'ERROR'
3+
let returnValue = ''
4+
for(let i = 0; i < num; i++) {
5+
returnValue = returnValue + string
6+
}
7+
return returnValue
38
}
49

510
module.exports = repeatString

0 commit comments

Comments
 (0)
0