Skip to content

Commit 8ef5170

Browse files
Update concept exercises to pass the linter (exercism#999)
1 parent 38f5df6 commit 8ef5170

File tree

53 files changed

+188
-180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+188
-180
lines changed

Diff for: .prettierrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"semi": true,
33
"singleQuote": true,
4-
"endOfLine": "lf"
4+
"endOfLine": "lf",
5+
"arrowParens": "always"
56
}

Diff for: concepts/array-analysis/introduction.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Introduction
22

3-
TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction
4-
53
In JavaScript, an array is a list-like structure with no fixed length which can hold any type of primitives or objects, or even mixed types. The array elements can be accessed by their index. Arrays are also given a bunch of built-in methods. Some of these built-in methods can analyse the contents of the array. Many of the built-in functions that analyse the contents of an array, take a [`predicate`][predicate_in_programming] as argument.
64

75
The built-in functions are meant to be used _instead of a `for` loop_ or the built-in `Array#forEach()`:

Diff for: concepts/array-destructuring/introduction.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Introduction
22

3-
TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction
4-
53
Javascript's array destructuring syntax is a concise way to extract values from an array and assign them to distinct variables.
64

75
In this example, each value in the `numberOfMoons` array is assigned to its corresponding planet:

Diff for: concepts/arrays/introduction.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Introduction
22

3-
TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction
4-
53
In Javascript, an array is a list-like structure with no fixed length which can hold any type of primitives or ojects, even mixed types. The array elements can be accesed by their index.
64

75
Example of an array declaration and accessing an element by index:

Diff for: concepts/basics/introduction.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Introduction
22

3-
TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction
4-
53
JavaScript is a dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles.
64

75
There are a few primary ways to assign values to names in JavaScript - using variables or constants. On Exercism, variables are always written in [camelCase][wiki-camel-case]; constants are written in [SCREAMING_SNAKE_CASE][wiki-snake-case].

Diff for: concepts/booleans/introduction.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
# Introduction
22

3-
TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction
4-
53
A boolean represents one of two values: `true` or `false`. Logical operators (`!`, `&&`, `||`) are typically used with boolean values and they return a boolean value.

Diff for: concepts/closures/introduction.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Introduction
22

3-
TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction
4-
53
**Closures** are a programming pattern in JavaScript which allows variables from an outer [lexical scope][wiki-lexical-scope] to be used inside of a nested block of code. JavaScript supports closures transparently, and they are often used without knowing what they are.
64

75
```javascript

Diff for: concepts/numbers/introduction.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Introduction
22

3-
TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction
4-
53
There are two different types of numbers in JavaScript:
64

75
- `number`: a numeric data type in the double-precision 64-bit floating point

Diff for: concepts/promises/introduction.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Introduction
22

3-
TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction
4-
53
The `Promise` object represents the eventual completion (or failure) of an
64
asynchronous operation, and its resulting value.
75

Diff for: concepts/recursion/introduction.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Introduction
22

3-
TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction
3+
TODO: add introduction for recursion concept

Diff for: concepts/rest-elements/introduction.md

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
11
# Introduction
22

3-
TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction
4-
5-
Javascript's array destructuring syntax is a concise way to extract values from an array and assign them to distinct variables.
6-
7-
In this example, each value in the `numberOfMoons` array is assigned to its corresponding planet:
8-
9-
```javascript
10-
const numberOfMoons = [0, 2, 14];
11-
const [venus, mars, neptune] = numberOfMoons;
12-
13-
neptune;
14-
// => 14
15-
```
3+
TODO: add introduction for rest-elements concept

Diff for: concepts/spread-elements/introduction.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Introduction
2+
3+
TODO: add introduction for spread-elements concept

Diff for: concepts/spread-operator/introduction.md

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
11
# Introduction
22

3-
TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction
4-
5-
Javascript's array destructuring syntax is a concise way to extract values from an array and assign them to distinct variables.
6-
7-
In this example, each value in the `numberOfMoons` array is assigned to its corresponding planet:
8-
9-
```javascript
10-
const numberOfMoons = [0, 2, 14];
11-
const [venus, mars, neptune] = numberOfMoons;
12-
13-
neptune;
14-
// => 14
15-
```
3+
TODO: add introduction for spread-operator concept

Diff for: concepts/strings/introduction.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Introduction
22

3-
TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction
4-
53
Strings are useful for holding data that can be represented in text form.
64
There are two ways to access an individual character in a string.
75

Diff for: exercises/concept/array-loops/.meta/config.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
"exercism_username": "SleeplessByte"
1212
}
1313
],
14-
"forked_from": [],
1514
"files": {
16-
"solution": [],
17-
"test": [],
15+
"solution": ["array-loops.js"],
16+
"test": ["array-loops.spec.js"],
1817
"exemplar": [".meta/exemplar.js"]
19-
}
18+
},
19+
"forked_from": []
2020
}

Diff for: exercises/concept/basics/.meta/config.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"exercism_username": "SleeplessByte"
66
}
77
],
8-
"forked_from": ["ruby/basics"],
98
"files": {
109
"solution": ["basics.js"],
1110
"test": ["basics.spec.js"],
12-
"exemplar": []
13-
}
11+
"exemplar": [".meta/examplar.js"]
12+
},
13+
"forked_from": ["ruby/basics"]
1414
}
File renamed without changes.

Diff for: exercises/concept/booleans/.meta/config.json

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2+
"authors": [
3+
{
4+
"github_username": "ovidiu141",
5+
"exercism_username": "ovidiu141"
6+
}
7+
],
28
"contributors": [
39
{
410
"github_username": "rishiosaur",
@@ -9,15 +15,10 @@
915
"exercism_username": "SleeplessByte"
1016
}
1117
],
12-
"authors": [
13-
{
14-
"github_username": "ovidiu141",
15-
"exercism_username": "ovidiu141"
16-
}
17-
],
1818
"files": {
1919
"solution": ["booleans.js"],
2020
"test": ["booleans.spec.js"],
21-
"exemplar": []
22-
}
21+
"exemplar": [".meta/exemplar.js"]
22+
},
23+
"forked_from": []
2324
}

Diff for: exercises/concept/closures/.meta/config.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@
55
"exercism_username": "neenjaw"
66
}
77
],
8+
"contributors": [
9+
{
10+
"github_username": "SleeplessByte",
11+
"exercism_username": "SleeplessByte"
12+
}
13+
],
814
"files": {
915
"solution": ["closures.js"],
1016
"test": ["closures.spec.js"],
11-
"exemplar": []
12-
}
17+
"exemplar": [".meta/exemplar.js"]
18+
},
19+
"forked_from": []
1320
}

Diff for: exercises/concept/elyses-analytic-enchantments/.meta/config.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"contributors": [],
32
"authors": [
43
{
54
"github_username": "peterchu999",
@@ -10,9 +9,11 @@
109
"exercism_username": "SleeplessByte"
1110
}
1211
],
12+
"contributors": [],
1313
"files": {
1414
"solution": ["enchantments.js"],
1515
"test": ["enchantments.spec.js"],
1616
"exemplar": [".meta/exemplar.js"]
17-
}
17+
},
18+
"forked_from": []
1819
}

Diff for: exercises/concept/elyses-destructured-enchantments/.meta/config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"solution": ["enchantments.js"],
1616
"test": ["enchantments.spec.js"],
1717
"exemplar": [".meta/exemplar.js"]
18-
}
18+
},
19+
"forked_from": []
1920
}
+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2+
"authors": [
3+
{
4+
"github_username": "ovidiu141",
5+
"exercism_username": "ovidiu141"
6+
}
7+
],
28
"contributors": [
39
{
410
"github_username": "peterchu999",
@@ -9,16 +15,10 @@
915
"exercism_username": "SleeplessByte"
1016
}
1117
],
12-
"authors": [
13-
{
14-
"github_username": "ovidiu141",
15-
"exercism_username": "ovidiu141"
16-
}
17-
],
18-
"forked_from": ["go/basic-slices"],
1918
"files": {
2019
"solution": ["enchantments.js"],
2120
"test": ["enchantments.spec.js"],
2221
"exemplar": [".meta/exemplar.js"]
23-
}
22+
},
23+
"forked_from": ["go/basic-slices"]
2424
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
{
2-
"contributors": [],
32
"authors": [
43
{
54
"github_username": "yyyc514",
65
"exercism_username": "ajoshguy"
76
}
87
],
8+
"contributors": [
9+
{
10+
"github_username": "SleeplessByte",
11+
"exercism_username": "SleeplessByte"
12+
}
13+
],
914
"files": {
1015
"solution": ["enchantments.js"],
1116
"test": ["enchantments.spec.js"],
12-
"exemplar": ["exemplar.js"]
13-
}
17+
"exemplar": [".meta/exemplar.js"]
18+
},
19+
"forked_from": []
1420
}

Diff for: exercises/concept/fruit-picker/.meta/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
"files": {
1515
"solution": ["fruit-picker.js"],
1616
"test": ["fruit-picker.spec.js"],
17-
"exemplar": []
17+
"exemplar": [".meta/exemplar.js"]
1818
}
1919
}

Diff for: exercises/concept/fruit-picker/.meta/env.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/// <reference path="../global.d.ts" />
2+
3+
// This file purely exist so that exemplar.js may live in this folder, without
4+
// that causing syntax errors.

Diff for: exercises/concept/fruit-picker/exemplar.js renamed to exercises/concept/fruit-picker/.meta/exemplar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-check
22

3-
import { checkStatus, checkInventory } from './grocer';
3+
import { checkStatus, checkInventory } from '../grocer';
44

55
/**
66
* Returns the service status as a boolean value

Diff for: exercises/concept/fruit-picker/fruit-picker.js

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1+
/// <reference path="./global.d.ts" />
2+
//
13
// @ts-check
4+
//
5+
// The lines above enable type checking for this file. Various IDEs interpret
6+
// the @ts-check and reference directives. Together, they give you helpful
7+
// autocompletion when implementing this exercise. You don't need to understand
8+
// them in order to use it.
9+
//
10+
// In your own projects, files, and code, you can play with @ts-check as well.
211

312
import { checkStatus, checkInventory } from './grocer';
413

Diff for: exercises/concept/lucky-numbers/.docs/instructions.md

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
11
# Instructions
22

3-
In this exercise you'll be writing code to understand the concepts of type conversion that you might encounter in your everyday code
4-
5-
Given two arrays made up of digits, write a function that turns the digits into numbers and then sums the numbers.
6-
73
## Tasks
84

95
## 1. Find the sum of two arrays
106

11-
Implement a function to calculate the sum of two array element given the array of two numbers:
7+
Given two arrays made up of digits, write a function that interprets the arrays as numbers and sums them:
128

139
```javascript
10+
// 123 becomes [1, 2, 3]
11+
// 7 becomes [0, 0, 7]
1412
twoSum([1, 2, 3], [0, 0, 7]);
1513
//=> 130
1614
```
1715

18-
The result should be a number and the array element only contains as integer
19-
2016
## 2. Determine if the number is lucky
2117

22-
After the calculator the owner would like to know the sum that he got is a lucky number or not. A number is said to be lucky if it is a palindrome.
18+
In this exercise a number is said to be lucky if it is a palindrome.
2319

2420
Implement a function to determine whether the number is lucky.
2521

2622
```javascript
2723
luckyNumber(1441);
2824
//=> true
25+
2926
luckyNumber(123);
3027
//=> false
3128
```
3229

3330
## 3. Dashify a number
3431

35-
Implement a function that interpolates a dash between each number, converting it to a string.
32+
Implement a function that takes a number and places a dash between each digit
3633

3734
```javascript
3835
dashify(1466);

0 commit comments

Comments
 (0)