From 3fb698bbe091cbaa8d5d3f2256ebfb776523448d Mon Sep 17 00:00:00 2001 From: Andinus Date: Wed, 25 Aug 2021 20:10:19 +0530 Subject: JS: Solve hello-world, two-fer, square-root --- javascript/hello-world/.eslintrc | 29 ++++++++++++++ javascript/hello-world/.npmrc | 1 + javascript/hello-world/README.md | 64 ++++++++++++++++++++++++++++++ javascript/hello-world/babel.config.js | 15 +++++++ javascript/hello-world/hello-world.js | 3 ++ javascript/hello-world/hello-world.spec.js | 7 ++++ javascript/hello-world/package.json | 37 +++++++++++++++++ 7 files changed, 156 insertions(+) create mode 100644 javascript/hello-world/.eslintrc create mode 100644 javascript/hello-world/.npmrc create mode 100644 javascript/hello-world/README.md create mode 100644 javascript/hello-world/babel.config.js create mode 100644 javascript/hello-world/hello-world.js create mode 100644 javascript/hello-world/hello-world.spec.js create mode 100644 javascript/hello-world/package.json (limited to 'javascript/hello-world') 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" +} -- cgit 1.4.1-2-gfad0