Skip to content

Update concept exercises to pass the linter #999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"semi": true,
"singleQuote": true,
"endOfLine": "lf"
"endOfLine": "lf",
"arrowParens": "always"
}
2 changes: 0 additions & 2 deletions concepts/array-analysis/introduction.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Introduction

TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction

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.

The built-in functions are meant to be used _instead of a `for` loop_ or the built-in `Array#forEach()`:
Expand Down
2 changes: 0 additions & 2 deletions concepts/array-destructuring/introduction.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Introduction

TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction

Javascript's array destructuring syntax is a concise way to extract values from an array and assign them to distinct variables.

In this example, each value in the `numberOfMoons` array is assigned to its corresponding planet:
Expand Down
2 changes: 0 additions & 2 deletions concepts/arrays/introduction.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Introduction

TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction

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.

Example of an array declaration and accessing an element by index:
Expand Down
2 changes: 0 additions & 2 deletions concepts/basics/introduction.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Introduction

TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction

JavaScript is a dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles.

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].
Expand Down
2 changes: 0 additions & 2 deletions concepts/booleans/introduction.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Introduction

TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction

A boolean represents one of two values: `true` or `false`. Logical operators (`!`, `&&`, `||`) are typically used with boolean values and they return a boolean value.
2 changes: 0 additions & 2 deletions concepts/closures/introduction.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Introduction

TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction

**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.

```javascript
Expand Down
2 changes: 0 additions & 2 deletions concepts/numbers/introduction.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Introduction

TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction

There are two different types of numbers in JavaScript:

- `number`: a numeric data type in the double-precision 64-bit floating point
Expand Down
2 changes: 0 additions & 2 deletions concepts/promises/introduction.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Introduction

TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction

The `Promise` object represents the eventual completion (or failure) of an
asynchronous operation, and its resulting value.

Expand Down
2 changes: 1 addition & 1 deletion concepts/recursion/introduction.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Introduction

TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction
TODO: add introduction for recursion concept
14 changes: 1 addition & 13 deletions concepts/rest-elements/introduction.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
# Introduction

TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction

Javascript's array destructuring syntax is a concise way to extract values from an array and assign them to distinct variables.

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

```javascript
const numberOfMoons = [0, 2, 14];
const [venus, mars, neptune] = numberOfMoons;

neptune;
// => 14
```
TODO: add introduction for rest-elements concept
3 changes: 3 additions & 0 deletions concepts/spread-elements/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Introduction

TODO: add introduction for spread-elements concept
14 changes: 1 addition & 13 deletions concepts/spread-operator/introduction.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
# Introduction

TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction

Javascript's array destructuring syntax is a concise way to extract values from an array and assign them to distinct variables.

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

```javascript
const numberOfMoons = [0, 2, 14];
const [venus, mars, neptune] = numberOfMoons;

neptune;
// => 14
```
TODO: add introduction for spread-operator concept
2 changes: 0 additions & 2 deletions concepts/strings/introduction.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Introduction

TODO: the content below is copied from the exercise introduction and probably needs rewriting to a proper concept introduction

Strings are useful for holding data that can be represented in text form.
There are two ways to access an individual character in a string.

Expand Down
8 changes: 4 additions & 4 deletions exercises/concept/array-loops/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"exercism_username": "SleeplessByte"
}
],
"forked_from": [],
"files": {
"solution": [],
"test": [],
"solution": ["array-loops.js"],
"test": ["array-loops.spec.js"],
"exemplar": [".meta/exemplar.js"]
}
},
"forked_from": []
}
6 changes: 3 additions & 3 deletions exercises/concept/basics/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"exercism_username": "SleeplessByte"
}
],
"forked_from": ["ruby/basics"],
"files": {
"solution": ["basics.js"],
"test": ["basics.spec.js"],
"exemplar": []
}
"exemplar": [".meta/examplar.js"]
},
"forked_from": ["ruby/basics"]
}
17 changes: 9 additions & 8 deletions exercises/concept/booleans/.meta/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"authors": [
{
"github_username": "ovidiu141",
"exercism_username": "ovidiu141"
}
],
"contributors": [
{
"github_username": "rishiosaur",
Expand All @@ -9,15 +15,10 @@
"exercism_username": "SleeplessByte"
}
],
"authors": [
{
"github_username": "ovidiu141",
"exercism_username": "ovidiu141"
}
],
"files": {
"solution": ["booleans.js"],
"test": ["booleans.spec.js"],
"exemplar": []
}
"exemplar": [".meta/exemplar.js"]
},
"forked_from": []
}
11 changes: 9 additions & 2 deletions exercises/concept/closures/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@
"exercism_username": "neenjaw"
}
],
"contributors": [
{
"github_username": "SleeplessByte",
"exercism_username": "SleeplessByte"
}
],
"files": {
"solution": ["closures.js"],
"test": ["closures.spec.js"],
"exemplar": []
}
"exemplar": [".meta/exemplar.js"]
},
"forked_from": []
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"contributors": [],
"authors": [
{
"github_username": "peterchu999",
Expand All @@ -10,9 +9,11 @@
"exercism_username": "SleeplessByte"
}
],
"contributors": [],
"files": {
"solution": ["enchantments.js"],
"test": ["enchantments.spec.js"],
"exemplar": [".meta/exemplar.js"]
}
},
"forked_from": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"solution": ["enchantments.js"],
"test": ["enchantments.spec.js"],
"exemplar": [".meta/exemplar.js"]
}
},
"forked_from": []
}
16 changes: 8 additions & 8 deletions exercises/concept/elyses-enchantments/.meta/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"authors": [
{
"github_username": "ovidiu141",
"exercism_username": "ovidiu141"
}
],
"contributors": [
{
"github_username": "peterchu999",
Expand All @@ -9,16 +15,10 @@
"exercism_username": "SleeplessByte"
}
],
"authors": [
{
"github_username": "ovidiu141",
"exercism_username": "ovidiu141"
}
],
"forked_from": ["go/basic-slices"],
"files": {
"solution": ["enchantments.js"],
"test": ["enchantments.spec.js"],
"exemplar": [".meta/exemplar.js"]
}
},
"forked_from": ["go/basic-slices"]
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
{
"contributors": [],
"authors": [
{
"github_username": "yyyc514",
"exercism_username": "ajoshguy"
}
],
"contributors": [
{
"github_username": "SleeplessByte",
"exercism_username": "SleeplessByte"
}
],
"files": {
"solution": ["enchantments.js"],
"test": ["enchantments.spec.js"],
"exemplar": ["exemplar.js"]
}
"exemplar": [".meta/exemplar.js"]
},
"forked_from": []
}
2 changes: 1 addition & 1 deletion exercises/concept/fruit-picker/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"files": {
"solution": ["fruit-picker.js"],
"test": ["fruit-picker.spec.js"],
"exemplar": []
"exemplar": [".meta/exemplar.js"]
}
}
4 changes: 4 additions & 0 deletions exercises/concept/fruit-picker/.meta/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/// <reference path="../global.d.ts" />

// This file purely exist so that exemplar.js may live in this folder, without
// that causing syntax errors.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check

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

/**
* Returns the service status as a boolean value
Expand Down
9 changes: 9 additions & 0 deletions exercises/concept/fruit-picker/fruit-picker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
/// <reference path="./global.d.ts" />
//
// @ts-check
//
// The lines above enable type checking for this file. Various IDEs interpret
// the @ts-check and reference directives. Together, they give you helpful
// autocompletion when implementing this exercise. You don't need to understand
// them in order to use it.
//
// In your own projects, files, and code, you can play with @ts-check as well.

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

Expand Down
15 changes: 6 additions & 9 deletions exercises/concept/lucky-numbers/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
# Instructions

In this exercise you'll be writing code to understand the concepts of type conversion that you might encounter in your everyday code

Given two arrays made up of digits, write a function that turns the digits into numbers and then sums the numbers.

## Tasks

## 1. Find the sum of two arrays

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

```javascript
// 123 becomes [1, 2, 3]
// 7 becomes [0, 0, 7]
twoSum([1, 2, 3], [0, 0, 7]);
//=> 130
```

The result should be a number and the array element only contains as integer

## 2. Determine if the number is lucky

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.
In this exercise a number is said to be lucky if it is a palindrome.

Implement a function to determine whether the number is lucky.

```javascript
luckyNumber(1441);
//=> true

luckyNumber(123);
//=> false
```

## 3. Dashify a number

Implement a function that interpolates a dash between each number, converting it to a string.
Implement a function that takes a number and places a dash between each digit

```javascript
dashify(1466);
Expand Down
Loading