Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2528636

Browse files
author
programmiri
committed
Add exercise Raindrops
1 parent a8208d9 commit 2528636

File tree

6 files changed

+174
-0
lines changed

6 files changed

+174
-0
lines changed

‎raindrops/.eslintrc‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"root": true,
3+
"parser": "babel-eslint",
4+
"parserOptions": {
5+
"ecmaVersion": 7,
6+
"sourceType": "module"
7+
},
8+
"env": {
9+
"es6": true,
10+
"node": true,
11+
"jest": true
12+
},
13+
"extends": [
14+
"eslint:recommended",
15+
"plugin:import/errors",
16+
"plugin:import/warnings"
17+
],
18+
"rules": {
19+
"linebreak-style": "off",
20+
21+
"import/extensions": "off",
22+
"import/no-default-export": "off",
23+
"import/no-unresolved": "off",
24+
"import/prefer-default-export": "off"
25+
}
26+
}

‎raindrops/README.md‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Raindrops
2+
3+
Convert a number to a string, the contents of which depend on the number's factors.
4+
5+
- If the number has 3 as a factor, output 'Pling'.
6+
- If the number has 5 as a factor, output 'Plang'.
7+
- If the number has 7 as a factor, output 'Plong'.
8+
- If the number does not have 3, 5, or 7 as a factor,
9+
just pass the number's digits straight through.
10+
11+
## Examples
12+
13+
- 28's factors are 1, 2, 4, **7**, 14, 28.
14+
- In raindrop-speak, this would be a simple "Plong".
15+
- 30's factors are 1, 2, **3**, **5**, 6, 10, 15, 30.
16+
- In raindrop-speak, this would be a "PlingPlang".
17+
- 34 has four factors: 1, 2, 17, and 34.
18+
- In raindrop-speak, this would be "34".
19+
20+
## Setup
21+
22+
Go through the setup instructions for Javascript to install the necessary
23+
dependencies:
24+
25+
[https://exercism.io/tracks/javascript/installation](https://exercism.io/tracks/javascript/installation)
26+
27+
## Requirements
28+
29+
Install assignment dependencies:
30+
31+
```bash
32+
$ npm install
33+
```
34+
35+
## Making the test suite pass
36+
37+
Execute the tests with:
38+
39+
```bash
40+
$ npm test
41+
```
42+
43+
In the test suites all tests but the first have been skipped.
44+
45+
Once you get a test passing, you can enable the next one by changing `xtest` to
46+
`test`.
47+
48+
## Source
49+
50+
A variation on a famous interview question intended to weed out potential candidates. [http://jumpstartlab.com](http://jumpstartlab.com)
51+
52+
## Submitting Incomplete Solutions
53+
54+
It's possible to submit an incomplete solution so you can see how others have
55+
completed the exercise.

‎raindrops/babel.config.js‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/env',
5+
{
6+
targets: {
7+
node: 'current',
8+
},
9+
useBuiltIns: false,
10+
},
11+
12+
],
13+
],
14+
};

‎raindrops/package.json‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "exercism-javascript",
3+
"version": "0.0.0",
4+
"description": "Exercism exercises in Javascript.",
5+
"author": "Katrina Owen",
6+
"private": true,
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/exercism/javascript"
10+
},
11+
"devDependencies": {
12+
"@babel/cli": "^7.2.3",
13+
"@babel/core": "^7.4.0",
14+
"@babel/preset-env": "^7.4.2",
15+
"@types/jest": "^24.0.13",
16+
"@types/node": "^12.0.4",
17+
"babel-eslint": "^10.0.1",
18+
"babel-jest": "^24.5.0",
19+
"eslint": "^5.15.3",
20+
"eslint-plugin-import": "^2.16.0",
21+
"jest": "^24.5.0"
22+
},
23+
"jest": {
24+
"modulePathIgnorePatterns": [
25+
"package.json"
26+
]
27+
},
28+
"scripts": {
29+
"test": "jest --no-cache ./*",
30+
"watch": "jest --no-cache --watch ./*",
31+
"lint": "eslint .",
32+
"lint-test": "eslint . && jest --no-cache ./* "
33+
},
34+
"license": "MIT",
35+
"dependencies": {}
36+
}

‎raindrops/raindrops.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//
2+
// This is only a SKELETON file for the 'Raindrops' exercise. It's been provided as a
3+
// convenience to get you started writing code faster.
4+
//
5+
6+
export const convert = () => {
7+
throw new Error("Remove this statement and implement this function");
8+
};

‎raindrops/raindrops.spec.js‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { convert } from './raindrops';
2+
3+
describe('Raindrops', () => {
4+
test('converts 1', () => expect(convert(1)).toEqual('1'));
5+
6+
xtest('converts 3', () => expect(convert(3)).toEqual('Pling'));
7+
8+
xtest('converts 5', () => expect(convert(5)).toEqual('Plang'));
9+
10+
xtest('converts 7', () => expect(convert(7)).toEqual('Plong'));
11+
12+
xtest('converts 6', () => expect(convert(6)).toEqual('Pling'));
13+
14+
xtest('converts 9', () => expect(convert(9)).toEqual('Pling'));
15+
16+
xtest('converts 10', () => expect(convert(10)).toEqual('Plang'));
17+
18+
xtest('converts 14', () => expect(convert(14)).toEqual('Plong'));
19+
20+
xtest('converts 15', () => expect(convert(15)).toEqual('PlingPlang'));
21+
22+
xtest('converts 21', () => expect(convert(21)).toEqual('PlingPlong'));
23+
24+
xtest('converts 25', () => expect(convert(25)).toEqual('Plang'));
25+
26+
xtest('converts 35', () => expect(convert(35)).toEqual('PlangPlong'));
27+
28+
xtest('converts 49', () => expect(convert(49)).toEqual('Plong'));
29+
30+
xtest('converts 52', () => expect(convert(52)).toEqual('52'));
31+
32+
xtest('converts 105', () => expect(convert(105)).toEqual('PlingPlangPlong'));
33+
34+
xtest('converts 12121', () => expect(convert(12121)).toEqual('12121'));
35+
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /