fix(curriculum) replace single-line blocks with multi-line blocks for… (#41526)

* fix(curriculum) replace single-line blocks with multi-line blocks for issue 51418

Data visualization and Coding Interview Prep portions.

* Update execute-a-markov-algorithm.md

Implemented as inline code blocks as discussed

* Adding missed blocks

* Last file added
This commit is contained in:
Laurent Labine
2021-03-25 15:43:13 +01:00
committed by GitHub
parent e55aa5c7bb
commit 8e22962523
18 changed files with 77 additions and 59 deletions

View File

@ -12,15 +12,21 @@ Now that you have worked through ES5, you are going to perform something similar
To create a new empty set:
`var set = new Set();`
```js
var set = new Set();
```
You can create a set with a value:
`var set = new Set(1);`
```js
var set = new Set(1);
```
You can create a set with an array:
`var set = new Set([1, 2, 3]);`
```js
var set = new Set([1, 2, 3]);
```
Once you have created a set, you can add the values you wish using the `add` method:

View File

@ -14,13 +14,17 @@ While binary heaps may be implemented as tree structures with nodes that contain
For instance, consider this array representation of a binary min heap:
`[ 6, 22, 30, 37, 63, 48, 42, 76 ]`
```js
[ 6, 22, 30, 37, 63, 48, 42, 76 ]
```
The root node is the first element, `6`. Its children are `22` and `30`. If we look at the relationship between the array indices of these values, for index `i` the children are `2 * i + 1` and `2 * i + 2`. Similarly, the element at index `0` is the parent of these two children at indices `1` and `2`. More generally, we can find the parent of a node at any index with the following: `Math.floor((i - 1) / 2)`. These patterns will hold true as the binary tree grows to any size. Finally, we can make a slight adjustment to make this arithmetic even easier by skipping the first element in the array. Doing this creates the following relationship for any element at a given index `i`:
Example array representation:
`[ null, 6, 22, 30, 37, 63, 48, 42, 76 ]`
```js
[ null, 6, 22, 30, 37, 63, 48, 42, 76 ]
```
An element's left child: `i * 2`

View File

@ -12,7 +12,9 @@ Let's practice removing items from an ES6 Set using the `delete` method.
First, create an ES6 Set:
`var set = new Set([1,2,3]);`
```js
var set = new Set([1,2,3]);
```
Now remove an item from your Set with the `delete` method.

View File

@ -10,7 +10,9 @@ dashedName: typed-arrays
Arrays are JavaScript objects that can hold a lot of different elements.
`var complexArr = [1, 5, "2", "Word", {"name": "James"}];`
```js
var complexArr = [1, 5, "2", "Word", {"name": "James"}];
```
Basically what happens in the background is that your browser will automatically give the right amount of memory space for that array. It will also change as needed if you add or remove data.

View File

@ -12,15 +12,21 @@ Let's look at the .has and .size methods available on the ES6 Set object.
First, create an ES6 Set
`var set = new Set([1,2,3]);`
```js
var set = new Set([1,2,3]);
```
The .has method will check if the value is contained within the set.
`var hasTwo = set.has(2);`
```js
var hasTwo = set.has(2);
```
The .size method will return an integer representing the size of the Set
`var howBig = set.size;`
```js
var howBig = set.size;
```
# --instructions--