diff options
Diffstat (limited to 'javascript/two-fer')
-rw-r--r-- | javascript/two-fer/.eslintrc | 29 | ||||
-rw-r--r-- | javascript/two-fer/.npmrc | 1 | ||||
-rw-r--r-- | javascript/two-fer/README.md | 75 | ||||
-rw-r--r-- | javascript/two-fer/babel.config.js | 15 | ||||
-rw-r--r-- | javascript/two-fer/package.json | 37 | ||||
-rw-r--r-- | javascript/two-fer/two-fer.js | 3 | ||||
-rw-r--r-- | javascript/two-fer/two-fer.spec.js | 15 |
7 files changed, 175 insertions, 0 deletions
diff --git a/javascript/two-fer/.eslintrc b/javascript/two-fer/.eslintrc new file mode 100644 index 0000000..b8dab20 --- /dev/null +++ b/javascript/two-fer/.eslintrc @@ -0,0 +1,29 @@ +{ + "root": true, + "parser": "babel-eslint", + "parserOptions": { + "ecmaVersion": 7, + "sourceType": "module" + }, + "globals": { + "BigInt": true + }, + "env": { + "es6": true, + "node": true, + "jest": true + }, + "extends": [ + "eslint:recommended", + "plugin:import/errors", + "plugin:import/warnings" + ], + "rules": { + "linebreak-style": "off", + + "import/extensions": "off", + "import/no-default-export": "off", + "import/no-unresolved": "off", + "import/prefer-default-export": "off" + } +} diff --git a/javascript/two-fer/.npmrc b/javascript/two-fer/.npmrc new file mode 100644 index 0000000..d26df80 --- /dev/null +++ b/javascript/two-fer/.npmrc @@ -0,0 +1 @@ +audit=false diff --git a/javascript/two-fer/README.md b/javascript/two-fer/README.md new file mode 100644 index 0000000..f5e3d28 --- /dev/null +++ b/javascript/two-fer/README.md @@ -0,0 +1,75 @@ +# Two Fer + +`Two-fer` or `2-fer` is short for two for one. One for you and one for me. + +Given a name, return a string with the message: + +```text +One for name, one for me. +``` + +Where "name" is the given name. + +However, if the name is missing, return the string: + +```text +One for you, one for me. +``` + +Here are some examples: + +|Name |String to return +|:-------|:------------------ +|Alice |One for Alice, one for me. +|Bob |One for Bob, one for me. +| |One for you, one for me. +|Zaphod |One for Zaphod, one for me. + +## Setup + +Go through the setup instructions for Javascript to install the necessary +dependencies: + +[https://exercism.io/tracks/javascript/installation](https://exercism.io/tracks/javascript/installation) + +## Requirements + +Please `cd` into exercise directory before running all below commands. + +Install assignment dependencies: + +```bash +$ npm install +``` + +## Making the test suite pass + +Execute the tests with: + +```bash +$ npm test +``` + +In the test suites all tests but the first have been skipped. + +Once you get a test passing, you can enable the next one by changing `xtest` to +`test`. + + +## Submitting Solutions + +Once you have a solution ready, you can submit it using: + +```bash +exercism submit two-fer.js +``` + +## Submitting Incomplete Solutions + +It's possible to submit an incomplete solution so you can see how others have +completed the exercise. + +## Exercise Source Credits + +[https://github.com/exercism/problem-specifications/issues/757](https://github.com/exercism/problem-specifications/issues/757) + diff --git a/javascript/two-fer/babel.config.js b/javascript/two-fer/babel.config.js new file mode 100644 index 0000000..5cec972 --- /dev/null +++ b/javascript/two-fer/babel.config.js @@ -0,0 +1,15 @@ +module.exports = { + presets: [ + [ + '@babel/preset-env', + { + targets: { + node: 'current', + }, + useBuiltIns: 'entry', + corejs: 3, + }, + ], + ], + plugins: ['@babel/plugin-syntax-bigint'], +}; diff --git a/javascript/two-fer/package.json b/javascript/two-fer/package.json new file mode 100644 index 0000000..d4dc05e --- /dev/null +++ b/javascript/two-fer/package.json @@ -0,0 +1,37 @@ +{ + "name": "@exercism/javascript", + "description": "Exercism exercises in Javascript.", + "author": "Katrina Owen", + "private": true, + "repository": { + "type": "git", + "url": "https://github.com/exercism/javascript" + }, + "devDependencies": { + "@babel/cli": "^7.12.10", + "@babel/core": "^7.12.10", + "@babel/plugin-syntax-bigint": "^7.8.3", + "@babel/preset-env": "^7.12.11", + "@types/jest": "^26.0.19", + "@types/node": "^14.14.14", + "babel-eslint": "^10.1.0", + "babel-jest": "^26.6.3", + "core-js": "^3.8.1", + "eslint": "^7.15.0", + "eslint-plugin-import": "^2.22.1", + "jest": "^26.6.3" + }, + "jest": { + "modulePathIgnorePatterns": [ + "package.json" + ] + }, + "scripts": { + "test": "jest --no-cache ./*", + "watch": "jest --no-cache --watch ./*", + "lint": "eslint ." + }, + "license": "MIT", + "dependencies": {}, + "version": "1.2.0" +} diff --git a/javascript/two-fer/two-fer.js b/javascript/two-fer/two-fer.js new file mode 100644 index 0000000..2349ad7 --- /dev/null +++ b/javascript/two-fer/two-fer.js @@ -0,0 +1,3 @@ +export const twoFer = (name = "you") => { + return "One for " + name + ", one for me."; +}; diff --git a/javascript/two-fer/two-fer.spec.js b/javascript/two-fer/two-fer.spec.js new file mode 100644 index 0000000..1c39a36 --- /dev/null +++ b/javascript/two-fer/two-fer.spec.js @@ -0,0 +1,15 @@ +import { twoFer } from './two-fer'; + +describe('twoFer()', () => { + test('no name given', () => { + expect(twoFer()).toEqual('One for you, one for me.'); + }); + + xtest('a name given', () => { + expect(twoFer('Alice')).toEqual('One for Alice, one for me.'); + }); + + xtest('another name given', () => { + expect(twoFer('Bob')).toEqual('One for Bob, one for me.'); + }); +}); |