diff --git a/config/.eslintignore b/.eslintignore similarity index 83% rename from config/.eslintignore rename to .eslintignore index 05b1cf3..82ff623 100644 --- a/config/.eslintignore +++ b/.eslintignore @@ -2,4 +2,4 @@ **/vendor/* **/*.min.js **/coverage/* -**/build/* +**/build/* \ No newline at end of file diff --git a/config/.eslintrc.json b/.eslintrc.json similarity index 99% rename from config/.eslintrc.json rename to .eslintrc.json index 886827f..b96d606 100644 --- a/config/.eslintrc.json +++ b/.eslintrc.json @@ -24,4 +24,4 @@ "semi": [ "error", "always" ], "linebreak-style": ["error", "unix"] } -} +} \ No newline at end of file diff --git a/config/.gitignore b/.gitignore similarity index 99% rename from config/.gitignore rename to .gitignore index 4745950..e24c600 100644 --- a/config/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/CHALLENGE.md b/CHALLENGE.md deleted file mode 100644 index 099aac4..0000000 --- a/CHALLENGE.md +++ /dev/null @@ -1,20 +0,0 @@ -![CF](https://camo.githubusercontent.com/70edab54bba80edb7493cad3135e9606781cbb6b/687474703a2f2f692e696d6775722e636f6d2f377635415363382e706e67) 01: Whiteboard Challenge -=== - -## Requirements -Write a function that takes in a numeric array and returns an object literal with three properties: -* the highest value -* the lowest value -* the average of all values - -## Submission Instructions - -1. With your assigned partner, pseudocode your solution on the whiteboard. Take a picture of your proposed solution for your repo. -1. Make a new branch and folder in your whiteboard challenge repository on GitHub. The name of the folder should be the same as the name of the challenge. -1. This folder should contain: - - A file named `solution.js` which contains the JavaScript solution - - A picture of your pseudocoded solution from the whiteboarding exercise - - A `README.md` which includes the problem domain -1. Complete the whiteboard challenge in your text editor, and verify that it's functional. -1. Make a pull request from your working branch to your master branch. -1. Submit a link to your PR on Canvas. diff --git a/README.md b/README.md deleted file mode 100644 index 23a8b20..0000000 --- a/README.md +++ /dev/null @@ -1,50 +0,0 @@ -![CF](https://camo.githubusercontent.com/70edab54bba80edb7493cad3135e9606781cbb6b/687474703a2f2f692e696d6775722e636f6d2f377635415363382e706e67) 01: Node Ecosystem -=== - -## Submission Instructions -* Work in a fork of this repository -* Work in a branch on your fork -* Write all of your code in a directory named `lab-` + `` **e.g.** `lab-susan` -* Open a pull request to this repository -* Submit on canvas a question and observation, how long you spent, and a link to your pull request - -## Configuration -Configure the root of your repository with the following files and directories. Thoughtfully name and organize any additional configuration or module files. - -* **README.md** - contains your documentation -* **.gitignore** - contains a [robust](http://gitignore.io) `.gitignore` file -* **.eslintrc.json** - contains the course linter configuration -* **.eslintignore** - contains the course linter ignore configuration -* **lib/** - contains module definitions -* **__test__/** - contains unit tests - -## Testing - -### Greet Module Tests -* Write a test that expects the greet module to return `null` when you supply non-string values -* Write a test the expects the greet module to return `'hello world'` - * This should happen when invoked with `'world'` as the first argument - -### Arithmetic Module Tests -* Test each method for proper use (invoded with number arguments) -* Test each method for inproper use (invoded with one or more non-numner arguments) - -## Feature Tasks - -### Greet Module -Create a NodeJS module in the `lib` directory named `greet.js`. This module should export a single function. -* The `greet` function should have a single parameter (arity of one) that should expect a string as it's input -* The `greet` function should return the input name, concatenated with "hello ": eg. ("hello susan") -* The `greet` function should return `null` if the input is not a string - -### Arithmetic Module -Create a NodeJS module in the `lib` directory named `arithmetic.js`. This module exports an object and should have `add` and `sub` methods that implement addition and subtraction. -* The `add` method should have a 2 parameters (airty of two) - * `if` either argument is a non-number the function should return `null` - * `else` return the sum of the 2 numbers -* The `sub` method should have 2 parameters (airty of two) - * `if` either argument is a non-number the function should return `null` - * `else` return the second parameter subtracted from the first parameter - -### Documentation -In your README.md file, describe the exported values of each module defined in your `lib` directory. Every function description should include it's airty (expected number of parameters), the expected data for each parameter (data-type and limitations), and the expected output behavior (for both valid and invalid use). Feel free to include any additional information that you would like. diff --git a/lab-melanie/README.md b/lab-melanie/README.md new file mode 100644 index 0000000..3bf12cf --- /dev/null +++ b/lab-melanie/README.md @@ -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. \ No newline at end of file diff --git a/lab-melanie/lib/arithmetic.js b/lab-melanie/lib/arithmetic.js new file mode 100644 index 0000000..c7b8c02 --- /dev/null +++ b/lab-melanie/lib/arithmetic.js @@ -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; +}; \ No newline at end of file diff --git a/lab-melanie/lib/greet.js b/lab-melanie/lib/greet.js new file mode 100644 index 0000000..c846408 --- /dev/null +++ b/lab-melanie/lib/greet.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = function(input) { + if (typeof input !== 'string') throw Error (null); + return `Hello ${input}`; +}; \ No newline at end of file diff --git a/lab-melanie/test/arithmetic-test.js b/lab-melanie/test/arithmetic-test.js new file mode 100644 index 0000000..453867e --- /dev/null +++ b/lab-melanie/test/arithmetic-test.js @@ -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'); + }); + }); +}); \ No newline at end of file diff --git a/lab-melanie/test/greet-test.js b/lab-melanie/test/greet-test.js new file mode 100644 index 0000000..ac84d36 --- /dev/null +++ b/lab-melanie/test/greet-test.js @@ -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'); + }); + }); +}); \ No newline at end of file