-
-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
172 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"root": true, | ||
"parser": "babel-eslint", | ||
"parserOptions": { | ||
"ecmaVersion": 7, | ||
"sourceType": "module" | ||
}, | ||
"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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Resistor Color | ||
|
||
Resistors have color coded bands, where each color maps to a number. The first 2 bands of a resistor have a simple encoding scheme: each color maps to a single number. | ||
|
||
These colors are encoded as follows: | ||
|
||
- Black: 0 | ||
- Brown: 1 | ||
- Red: 2 | ||
- Orange: 3 | ||
- Yellow: 4 | ||
- Green: 5 | ||
- Blue: 6 | ||
- Violet: 7 | ||
- Grey: 8 | ||
- White: 9 | ||
|
||
Mnemonics map the colors to the numbers, that, when stored as an array, happen to map to their index in the array: Better Be Right Or Your Great Big Values Go Wrong. | ||
|
||
More information on the color encoding of resistors can be found in the [Electronic color code Wikipedia article](https://en.wikipedia.org/wiki/Electronic_color_code) | ||
|
||
## 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 | ||
|
||
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 Incomplete Solutions | ||
|
||
It's possible to submit an incomplete solution so you can see how others have completed the exercise. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = { | ||
presets: [ | ||
[ | ||
'@babel/env', | ||
{ | ||
targets: { | ||
node: 'current', | ||
}, | ||
useBuiltIns: false, | ||
}, | ||
|
||
], | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const COLORS = [ | ||
'black', 'brown', 'red', 'orange', 'yellow', 'green', | ||
'blue', 'violet', 'grey', 'white', | ||
]; | ||
|
||
export const colorCode = color => COLORS.indexOf(color) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "exercism-javascript", | ||
"version": "0.0.0", | ||
"description": "Exercism exercises in Javascript.", | ||
"author": "Katrina Owen", | ||
"private": true, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/exercism/javascript" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.2.3", | ||
"@babel/core": "^7.4.0", | ||
"@babel/preset-env": "^7.4.2", | ||
"babel-eslint": "^10.0.1", | ||
"babel-jest": "^24.5.0", | ||
"eslint": "^5.15.3", | ||
"eslint-plugin-import": "^2.16.0", | ||
"jest": "^24.5.0" | ||
}, | ||
"jest": { | ||
"modulePathIgnorePatterns": [ | ||
"package.json" | ||
] | ||
}, | ||
"scripts": { | ||
"test": "jest --no-cache ./*", | ||
"watch": "jest --no-cache --watch ./*", | ||
"lint": "eslint .", | ||
"lint-test": "eslint . && jest --no-cache ./* " | ||
}, | ||
"license": "MIT", | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { colorCode, COLORS } from './resistor-color' | ||
|
||
describe('ResistorColor', () => { | ||
describe('Color codes', () => { | ||
test('Black', () => { | ||
expect(colorCode("black")).toEqual(0) | ||
}) | ||
|
||
xtest('White', () => { | ||
expect(colorCode("white")).toEqual(9) | ||
}) | ||
|
||
xtest('Orange', () => { | ||
expect(colorCode("orange")).toEqual(3) | ||
}) | ||
}) | ||
|
||
xtest('Colors', () => { | ||
expect(COLORS).toEqual(["black","brown","red","orange","yellow","green","blue","violet","grey","white"]) | ||
}) | ||
}) |