summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--javascript/hello-world/.eslintrc29
-rw-r--r--javascript/hello-world/.npmrc1
-rw-r--r--javascript/hello-world/README.md64
-rw-r--r--javascript/hello-world/babel.config.js15
-rw-r--r--javascript/hello-world/hello-world.js3
-rw-r--r--javascript/hello-world/hello-world.spec.js7
-rw-r--r--javascript/hello-world/package.json37
-rw-r--r--javascript/square-root/.eslintrc29
-rw-r--r--javascript/square-root/.npmrc1
-rw-r--r--javascript/square-root/README.md61
-rw-r--r--javascript/square-root/babel.config.js15
-rw-r--r--javascript/square-root/package.json36
-rw-r--r--javascript/square-root/square-root.js3
-rw-r--r--javascript/square-root/square-root.spec.js22
-rw-r--r--javascript/two-fer/.eslintrc29
-rw-r--r--javascript/two-fer/.npmrc1
-rw-r--r--javascript/two-fer/README.md75
-rw-r--r--javascript/two-fer/babel.config.js15
-rw-r--r--javascript/two-fer/package.json37
-rw-r--r--javascript/two-fer/two-fer.js3
-rw-r--r--javascript/two-fer/two-fer.spec.js15
21 files changed, 498 insertions, 0 deletions
diff --git a/javascript/hello-world/.eslintrc b/javascript/hello-world/.eslintrc
new file mode 100644
index 0000000..b8dab20
--- /dev/null
+++ b/javascript/hello-world/.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/hello-world/.npmrc b/javascript/hello-world/.npmrc
new file mode 100644
index 0000000..d26df80
--- /dev/null
+++ b/javascript/hello-world/.npmrc
@@ -0,0 +1 @@
+audit=false
diff --git a/javascript/hello-world/README.md b/javascript/hello-world/README.md
new file mode 100644
index 0000000..21fe8c9
--- /dev/null
+++ b/javascript/hello-world/README.md
@@ -0,0 +1,64 @@
+# Hello World
+
+The classical introductory exercise. Just say "Hello, World!".
+
+["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
+the traditional first program for beginning programming in a new language
+or environment.
+
+The objectives are simple:
+
+- Write a function that returns the string "Hello, World!".
+- Run the test suite and make sure that it succeeds.
+- Submit your solution and check it at the website.
+
+If everything goes well, you will be ready to fetch your first real exercise.
+
+## 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 hello-world.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
+
+This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
+
diff --git a/javascript/hello-world/babel.config.js b/javascript/hello-world/babel.config.js
new file mode 100644
index 0000000..5cec972
--- /dev/null
+++ b/javascript/hello-world/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/hello-world/hello-world.js b/javascript/hello-world/hello-world.js
new file mode 100644
index 0000000..7e071c7
--- /dev/null
+++ b/javascript/hello-world/hello-world.js
@@ -0,0 +1,3 @@
+export const hello = () => {
+    return "Hello, World!";
+};
diff --git a/javascript/hello-world/hello-world.spec.js b/javascript/hello-world/hello-world.spec.js
new file mode 100644
index 0000000..cd0b7ec
--- /dev/null
+++ b/javascript/hello-world/hello-world.spec.js
@@ -0,0 +1,7 @@
+import { hello } from './hello-world';
+
+describe('Hello World', () => {
+  test('Say Hi!', () => {
+    expect(hello()).toEqual('Hello, World!');
+  });
+});
diff --git a/javascript/hello-world/package.json b/javascript/hello-world/package.json
new file mode 100644
index 0000000..b642b30
--- /dev/null
+++ b/javascript/hello-world/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.1.0"
+}
diff --git a/javascript/square-root/.eslintrc b/javascript/square-root/.eslintrc
new file mode 100644
index 0000000..b8dab20
--- /dev/null
+++ b/javascript/square-root/.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/square-root/.npmrc b/javascript/square-root/.npmrc
new file mode 100644
index 0000000..d26df80
--- /dev/null
+++ b/javascript/square-root/.npmrc
@@ -0,0 +1 @@
+audit=false
diff --git a/javascript/square-root/README.md b/javascript/square-root/README.md
new file mode 100644
index 0000000..be243d3
--- /dev/null
+++ b/javascript/square-root/README.md
@@ -0,0 +1,61 @@
+# Square Root
+
+Given a natural radicand, return its square root.
+
+Note that the term "radicand" refers to the number for which the root is to be determined. That is, it is the number under the root symbol.
+
+Check out the Wikipedia pages on [square root](https://en.wikipedia.org/wiki/Square_root) and [methods of computing square roots](https://en.wikipedia.org/wiki/Methods_of_computing_square_roots).
+
+Recall also that natural numbers are positive real whole numbers (i.e. 1, 2, 3 and up).
+
+The idea is not to use the built-in javascript functions such as `Math.sqrt(x)`, `x ** 0.5` or `x ** (1/2)`, it's to build your own.
+
+
+## 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 square-root.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
+
+wolf99 [https://github.com/exercism/problem-specifications/pull/1582](https://github.com/exercism/problem-specifications/pull/1582)
+
diff --git a/javascript/square-root/babel.config.js b/javascript/square-root/babel.config.js
new file mode 100644
index 0000000..5cec972
--- /dev/null
+++ b/javascript/square-root/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/square-root/package.json b/javascript/square-root/package.json
new file mode 100644
index 0000000..90f82c9
--- /dev/null
+++ b/javascript/square-root/package.json
@@ -0,0 +1,36 @@
+{
+  "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": {}
+}
diff --git a/javascript/square-root/square-root.js b/javascript/square-root/square-root.js
new file mode 100644
index 0000000..50c3634
--- /dev/null
+++ b/javascript/square-root/square-root.js
@@ -0,0 +1,3 @@
+export const squareRoot = (num) => {
+    return Math.sqrt(num);
+};
diff --git a/javascript/square-root/square-root.spec.js b/javascript/square-root/square-root.spec.js
new file mode 100644
index 0000000..3db6fcb
--- /dev/null
+++ b/javascript/square-root/square-root.spec.js
@@ -0,0 +1,22 @@
+import { squareRoot } from './square-root';
+
+describe('Square root', () => {
+    test('root of 1', () => {
+        expect(squareRoot(1)).toEqual(1);
+    });
+    test('root of 4', () => {
+        expect(squareRoot(4)).toEqual(2);
+    });
+    test('root of 5', () => {
+        expect(squareRoot(25)).toEqual(5);
+    });
+    test('root of 81', () => {
+        expect(squareRoot(81)).toEqual(9);
+    });
+    test('root of 196', () => {
+        expect(squareRoot(196)).toEqual(14);
+    });
+    test('root of 65025', () => {
+        expect(squareRoot(65025)).toEqual(255);
+    });
+});
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.');
+  });
+});