Browse Source

ecmascrip?

master
Ben Harris 3 years ago
parent
commit
6864077c0a
  1. 9
      ecmascript/.gitignore
  2. 51
      ecmascript/hello-world/README.md
  3. 7
      ecmascript/hello-world/hello-world.js
  4. 9
      ecmascript/hello-world/hello-world.spec.js
  5. 6248
      ecmascript/hello-world/package-lock.json
  6. 76
      ecmascript/hello-world/package.json
  7. 63
      ecmascript/leap/README.md
  8. 23
      ecmascript/leap/leap.spec.js
  9. 70
      ecmascript/leap/package.json

9
ecmascript/.gitignore

@ -0,0 +1,9 @@
*.swp
.DS_Store
npm-debug.log
tmp
bin/configlet
bin/configlet.exe
node_modules
.idea
babel-output

51
ecmascript/hello-world/README.md

@ -0,0 +1,51 @@
# 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 ECMAScript to
install the necessary dependencies:
http://exercism.io/languages/ecmascript/installation
## Requirements
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`.
## Source
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)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

7
ecmascript/hello-world/hello-world.js

@ -0,0 +1,7 @@
class HelloWorld {
hello() {
return "Hello, World!"
}
}
export default HelloWorld;

9
ecmascript/hello-world/hello-world.spec.js

@ -0,0 +1,9 @@
import HelloWorld from './hello-world';
describe('Hello World', () => {
const greeter = new HelloWorld();
test('says hello', () => {
expect(greeter.hello()).toEqual('Hello, World!');
});
});

6248
ecmascript/hello-world/package-lock.json
File diff suppressed because it is too large
View File

76
ecmascript/hello-world/package.json

@ -0,0 +1,76 @@
{
"name": "xecmascript",
"version": "0.0.0",
"description": "Exercism exercises in ECMAScript 6.",
"author": "Katrina Owen",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/exercism/xecmascript"
},
"devDependencies": {
"babel-jest": "^21.2.0",
"babel-plugin-transform-builtin-extend": "^1.1.2",
"babel-preset-env": "^1.4.0",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.0.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^5.0.1",
"eslint-plugin-react": "^7.0.1",
"jest": "^21.2.1"
},
"jest": {
"modulePathIgnorePatterns": [
"package.json"
]
},
"babel": {
"presets": [
[
"env",
{
"node": "current"
}
]
],
"plugins": [
[
"babel-plugin-transform-builtin-extend",
{
"globals": [
"Error"
]
}
],
[
"transform-regenerator"
]
]
},
"scripts": {
"test": "jest --no-cache ./*",
"watch": "jest --no-cache --watch ./*",
"lint": "eslint .",
"lint-test": "eslint . && jest --no-cache ./* "
},
"eslintConfig": {
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": "airbnb",
"rules": {
"import/no-unresolved": "off",
"import/extensions": "off"
}
},
"licenses": [
"MIT"
],
"dependencies": {}
}

63
ecmascript/leap/README.md

@ -0,0 +1,63 @@
# Leap
Given a year, report if it is a leap year.
The tricky thing here is that a leap year in the Gregorian calendar occurs:
```plain
on every year that is evenly divisible by 4
except every year that is evenly divisible by 100
unless the year is also evenly divisible by 400
```
For example, 1997 is not a leap year, but 1996 is. 1900 is not a leap
year, but 2000 is.
If your language provides a method in the standard library that does
this look-up, pretend it doesn't exist and implement it yourself.
## Notes
Though our exercise adopts some very simple rules, there is more to
learn!
For a delightful, four minute explanation of the whole leap year
phenomenon, go watch [this youtube video][video].
[video]: http://www.youtube.com/watch?v=xX96xng7sAE
## Setup
Go through the setup instructions for ECMAScript to
install the necessary dependencies:
http://exercism.io/languages/ecmascript/installation
## Requirements
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`.
## Source
JavaRanch Cattle Drive, exercise 3 [http://www.javaranch.com/leap.jsp](http://www.javaranch.com/leap.jsp)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

23
ecmascript/leap/leap.spec.js

@ -0,0 +1,23 @@
import Year from './leap';
describe('A leap year', () => {
test('year not divisible by 4: common year', () => {
const year = new Year(2015);
expect(year.isLeap()).toBeFalsy();
});
xtest('year divisible by 4, not divisible by 100: leap year', () => {
const year = new Year(2016);
expect(year.isLeap()).toBeTruthy();
});
xtest('year divisible by 100, not divisible by 400: common year', () => {
const year = new Year(2100);
expect(year.isLeap()).toBeFalsy();
});
xtest('year divisible by 400: leap year', () => {
const year = new Year(2000);
expect(year.isLeap()).toBeTruthy();
});
});

70
ecmascript/leap/package.json

@ -0,0 +1,70 @@
{
"name": "xecmascript",
"version": "0.0.0",
"description": "Exercism exercises in ECMAScript 6.",
"author": "Katrina Owen",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/exercism/xecmascript"
},
"devDependencies": {
"babel-jest": "^21.2.0",
"babel-plugin-transform-builtin-extend": "^1.1.2",
"babel-preset-env": "^1.4.0",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.0.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^5.0.1",
"eslint-plugin-react": "^7.0.1",
"jest": "^21.2.1"
},
"jest": {
"modulePathIgnorePatterns": [
"package.json"
]
},
"babel": {
"presets": [["env",{"node": "current"}]
],
"plugins": [
[
"babel-plugin-transform-builtin-extend",
{
"globals": [
"Error"
]
}
],
[
"transform-regenerator"
]
]
},
"scripts": {
"test": "jest --no-cache ./*",
"watch": "jest --no-cache --watch ./*",
"lint": "eslint .",
"lint-test": "eslint . && jest --no-cache ./* "
},
"eslintConfig": {
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": "airbnb",
"rules": {
"import/no-unresolved": "off",
"import/extensions": "off"
}
},
"licenses": [
"MIT"
],
"dependencies": {}
}
Loading…
Cancel
Save