Skip to content

Commit d8e5d72

Browse files
committed
Rewrite for JS skills-based
1 parent 16ba1c2 commit d8e5d72

8 files changed

+364
-151
lines changed

.gitignore

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
# Created by https://www.gitignore.io/api/node
3+
4+
### Node ###
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
10+
# Runtime data
11+
pids
12+
*.pid
13+
*.seed
14+
15+
# Directory for instrumented libs generated by jscoverage/JSCover
16+
lib-cov
17+
18+
# Coverage directory used by tools like istanbul
19+
coverage
20+
21+
# nyc test coverage
22+
.nyc_output
23+
24+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
25+
.grunt
26+
27+
# node-waf configuration
28+
.lock-wscript
29+
30+
# Compiled binary addons (http://nodejs.org/api/addons.html)
31+
build/Release
32+
33+
# Dependency directories
34+
node_modules
35+
jspm_packages
36+
37+
# Optional npm cache directory
38+
.npm
39+
40+
# Optional REPL history
41+
.node_repl_history
42+
43+
.results.json

README.md

+195-97
Large diffs are not rendered by default.

array.js

-1
This file was deleted.

arrays.js

Whitespace-only changes.

package.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "javascript-arrays",
3+
"version": "0.1.0",
4+
"description": "Introduction to arrays in JavaScript in Learn",
5+
"main": "array.js",
6+
"directories": {
7+
"test": "test"
8+
},
9+
"scripts": {
10+
"test": "mocha -R mocha-multi --reporter-options nyan=-,json=.results.json"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/learn-co-curriculum/javascript-arrays.git"
15+
},
16+
"keywords": [
17+
"learn",
18+
"flatiron",
19+
"javascript",
20+
"arrays"
21+
],
22+
"license": "SEE LICENSE IN LICENSE.md",
23+
"bugs": {
24+
"url": "https://github.com/learn-co-curriculum/javascript-arrays/issues"
25+
},
26+
"homepage": "https://github.com/learn-co-curriculum/javascript-arrays#readme",
27+
"devDependencies": {
28+
"chai": "^3.5.0",
29+
"jsdom": "^9.0.0",
30+
"mocha": "^2.4.5",
31+
"mocha-jsdom": "^1.1.0",
32+
"mocha-multi": "^0.9.0"
33+
}
34+
}

requires.yml

-6
This file was deleted.

spec/array-spec.js

-47
This file was deleted.

test/arrays-test.js

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*global describe, it */
2+
3+
const expect = require('chai').expect
4+
const fs = require('fs')
5+
const jsdom = require('mocha-jsdom')
6+
const path = require('path')
7+
8+
describe('arrays', () => {
9+
jsdom({
10+
src: fs.readFileSync(path.resolve(__dirname, '..', 'arrays.js'), 'utf-8')
11+
})
12+
13+
describe('chocolateBars', () => {
14+
it('is an array containing "snickers", "hundred grand", "kitkat", and "skittles"', () => {
15+
expect(chocolateBars).to.eql['snickers', 'hundred grand', 'kitkat', 'skittles']
16+
})
17+
})
18+
19+
describe('addElementToBeginningOfArray(array, element)', () => {
20+
it('adds an `element` to the beginning of an `array`', () => {
21+
expect(addElementToBeginningOfArray([1], 'foo')).to.eql(['foo', 1])
22+
})
23+
24+
it('does not alter `array`', () => {
25+
const array = [1]
26+
27+
addElementToBeginningOfArray(array, 'foo')
28+
29+
expect(array).to.eql(array)
30+
})
31+
})
32+
33+
describe('descructivelyAddElementToBeginningOfArray(array, element)', () => {
34+
it('adds an `element` to the beginning of an `array`', () => {
35+
expect(descructivelyAddElementToBeginningOfArray([1], 'foo')).to.eql(['foo', 1])
36+
})
37+
38+
it('alters `array`', () => {
39+
const array = [1]
40+
41+
descructivelyAddElementToBeginningOfArray(array, 'foo')
42+
43+
expect(array).to.eql(['foo', 1])
44+
})
45+
})
46+
47+
describe('addElementToEndOfArray(array, element)', () => {
48+
it('adds an `element` to the end of an `array`', () => {
49+
expect(addElementToEndOfArray([1], 'foo')).to.eql([1, 'foo'])
50+
})
51+
52+
it('does not alter `array`', () => {
53+
const array = [1]
54+
55+
addElementToEndOfArray(array, 'foo')
56+
57+
expect(array).to.eql(array)
58+
})
59+
})
60+
61+
describe('destructivelyAddElementToEndOfArray(array, element)', () => {
62+
it('adds an `element` to the end of an `array`', () => {
63+
expect(destructivelyAddElementToEndOfArray([1], 'foo')).to.eql([1, 'foo'])
64+
})
65+
66+
it('alters `array`', () => {
67+
const array = [1]
68+
69+
destructivelyAddElementToEndOfArray(array, 'foo')
70+
71+
expect(array).to.eql([1, 'foo'])
72+
})
73+
})
74+
75+
describe('accessElementAtArray(array, index)', () => {
76+
it('accesses the element in `array` at the given `index`', () => {
77+
expect(accessElementInArray([1, 2, 3], 2)).to.equal(3)
78+
})
79+
})
80+
81+
describe('removeElementFromBeginningOfArray(array)', () => {
82+
it('removes the first element from the `array`', () => {
83+
expect(removeElementFromBeginningOfArray([1, 2, 3])).to.eql([2, 3])
84+
})
85+
})
86+
87+
describe('removeElementFromEndOfArray(array)', () => {
88+
it('removes the last element from the `array`', () => {
89+
expect(removeElementFromEndOfArray([1, 2, 3])).to.eql([1, 2])
90+
})
91+
})
92+
})

0 commit comments

Comments
 (0)