Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/.eslintignore → .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
**/vendor/*
**/*.min.js
**/coverage/*
**/build/*
**/build/*
2 changes: 1 addition & 1 deletion config/.eslintrc.json → .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
"semi": [ "error", "always" ],
"linebreak-style": ["error", "unix"]
}
}
}
2 changes: 1 addition & 1 deletion config/.gitignore → .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,4 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/vim,osx,node,linux,windows
# End of https://www.gitignore.io/api/vim,osx,node,linux,windows
20 changes: 0 additions & 20 deletions CHALLENGE.md

This file was deleted.

50 changes: 0 additions & 50 deletions README.md

This file was deleted.

10 changes: 10 additions & 0 deletions lab-melanie/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
![CF](https://camo.githubusercontent.com/70edab54bba80edb7493cad3135e9606781cbb6b/687474703a2f2f692e696d6775722e636f6d2f377635415363382e706e67) 01: Node Ecosystem
===

### Module Documentation

#### Greet Module
The `greet.js` module in the `lib` directory exports a single function. It has a single arity (parameter) with a string as its expected type. Should it receive the appropriate input, the output will be concatenated with "Hello". Should another data type be used, a null error will be thrown.

#### Arithmetic Module
The `arithmetic.js` module in the `lib` directory exports an object with two methods. Both methods have an arity of two, both of which are expected to be integers. Should the `add` method receive the appropriate inputs, the output will be the sum of both inputs. Similarly, the `sub` method will subtract the second parameter from the first. Should another data type be used in either method, a null error will be thrown.
13 changes: 13 additions & 0 deletions lab-melanie/lib/arithmetic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

module.exports = exports = {};

exports.add = function(x, y) {
if (typeof x !== 'number' || typeof y !== 'number') throw new Error(null);
return x + y;
};

exports.sub = function(x, y) {
if (typeof x !== 'number' || typeof y !== 'number') throw new Error(null);
return y - x;
};
6 changes: 6 additions & 0 deletions lab-melanie/lib/greet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

module.exports = function(input) {
if (typeof input !== 'string') throw Error (null);
return `Hello ${input}`;
};
29 changes: 29 additions & 0 deletions lab-melanie/test/arithmetic-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';

const arithmetic = require('../lib/arithmetic.js');
const assert = require('assert');

describe('Arithmetic Module', function() {
describe('#add', function() {
it('should return 8', function() {
var result = arithmetic.add(3, 5);
assert.ok(result === 8, 'not equal to 8');
});
it('should throw null error if either argument is a non-number', function() {
assert.throws(function() {
arithmetic.add(2,'2');
}, 'error not thrown');
});
});
describe('#sub', function() {
it('should return 3', function() {
var result = arithmetic.sub(3,6);
assert.ok(result === 3, 'not equal to 3');
});
it('should throw null error if either argument is a non-number', function() {
assert.throws(function() {
arithmetic.sub(2,'2');
}, 'error not thrown');
});
});
});
18 changes: 18 additions & 0 deletions lab-melanie/test/greet-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

const greet = require('../lib/greet.js');
const assert = require('assert');

describe('Greet Module', function() {
describe('#function', function() {
it('should return Hello world', function() {
var result = greet('world');
assert.ok(result === 'Hello world', 'not equal to Hello world');
});
it('should return null if input is not a string', function() {
assert.throws(function() {
greet(2);
}, 'error not thrown');
});
});
});