Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
phuocng committed Jan 25, 2022
1 parent 94c83a6 commit 68318fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion snippets/array/compare-two-arrays-regardless-of-order.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ category: Array

```js
// `a` and `b` are arrays
const isEqual = (a, b) => JSON.stringify([...(new Set(a))].sort()) === JSON.stringify([...(new Set(b))].sort());
const isEqual = (a, b) => JSON.stringify([...new Set(a)].sort()) === JSON.stringify([...new Set(b)].sort());
```

**TypeScript version**
Expand Down
10 changes: 5 additions & 5 deletions snippets/array/intersperse-element-between-elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ category: Array
**JavaScript version**

```js
const intersperse = (a, s) => [...Array(2 * a.length - 1)].map((_, i) => (i % 2 ? s : a[i / 2]))
const intersperse = (a, s) => [...Array(2 * a.length - 1)].map((_, i) => (i % 2 ? s : a[i / 2]));
```

**TypeScript version**

```ts
const intersperse = <T>(a: T[], s: T): T[] => [...Array(2 * a.length - 1)].map((_, i) => (i % 2 ? s : a[i / 2]))
const intersperse = <T>(a: T[], s: T): T[] => [...Array(2 * a.length - 1)].map((_, i) => (i % 2 ? s : a[i / 2]));
```

**Examples**

```tsx
intersperse(['A', 'B', 'C'], '/') // ['A', '/', 'B', '/', 'C']
intersperse([<li>A</li>, <li>B</li>, <li>C</li>], <li>/</li>) // [<li>A</li>, <li>/</li>, <li>B</li>, <li>/</li>, <li>C</li>]
```
intersperse(['A', 'B', 'C'], '/'); // ['A', '/', 'B', '/', 'C']
intersperse([<li>A</li>, <li>B</li>, <li>C</li>], <li>/</li>); // [<li>A</li>, <li>/</li>, <li>B</li>, <li>/</li>, <li>C</li>]
```

0 comments on commit 68318fe

Please sign in to comment.