fix(curriculum): typos and spacing in lectures and reviews (#60077)

This commit is contained in:
Supravisor
2025-05-05 22:16:29 -07:00
committed by GitHub
parent abd9e3ff3e
commit 3e9c13bb43
9 changed files with 22 additions and 22 deletions
@@ -12,7 +12,7 @@ Watch the video or read the transcript and answer the questions below.
# --transcript--
what is ASCII and how does it work with `charCodeAt()` and `fromCharCode()`?
What is ASCII and how does it work with `charCodeAt()` and `fromCharCode()`?
In programming, understanding how characters are represented as numbers is fundamental. This is where ASCII comes in. ASCII, short for American Standard Code for Information Interchange, is a character encoding standard used in computers to represent text. It assigns a numeric value to each character, which is universally recognized by machines.
@@ -22,7 +22,7 @@ function greet() {
}
```
In this example, we have declared a function called `greet`. Inside that function, we have a `console.log` that logs the message `Hello, Jessica!`. If we tried to run this code, we would not see the message appear in the console. This because we need to call the function.
In this example, we have declared a function called `greet`. Inside that function, we have a `console.log` that logs the message `Hello, Jessica!`. If we tried to run this code, we would not see the message appear in the console. This is because we need to call the function.
A function call, or or invocation, is when we actually use or execute the function. To call a function, you will need to reference the function name followed by a set of parentheses:
@@ -23,8 +23,8 @@ Here is an example of using the `map` method on an array of numbers:
```js
const numbers = [1, 2, 3, 4, 5];
const doubled = numbers.map((num) => num * 2);
console.log(numbers); // [1,2,3,4,5]
console.log(doubled); // [2,4,6,8,10]
console.log(numbers); // [1, 2, 3, 4, 5]
console.log(doubled); // [2, 4, 6, 8, 10]
```
To create a new array where each number is doubled, we are using the `map` method. The `map` method accepts a callback function where the function is called on every single element in the array.
@@ -38,7 +38,7 @@ Our goal is to sort the array in alphabetical order. We can do this by calling t
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort();
console.log(fruits); // ["Apple","Banana","Mango","Orange"]
console.log(fruits); // ["Apple", "Banana", "Mango", "Orange"]
```
The result will be a sorted array of fruits in alphabetical order starting with the fruit `Apple`.
@@ -55,7 +55,7 @@ If we try to use the `sort` method on this `numbers` array, we will get unexpect
const numbers = [414, 200, 5, 10, 3];
numbers.sort();
console.log(numbers); // [10,200,3,414,5]
console.log(numbers); // [10, 200, 3, 414, 5]
```
We expected to see the result `[3, 5, 10, 200, 414]`, but instead we got `[10, 200, 3, 414, 5]`.
@@ -75,7 +75,7 @@ const numbers = [414, 200, 5, 10, 3];
numbers.sort((a, b) => a - b);
console.log(numbers); // [3,5,10,200,414]
console.log(numbers); // [3, 5, 10, 200, 414]
```
The parameters `a` and `b` are the two elements being compared. The compare function should return a negative value if `a` should come before `b`, a positive value if `a` should come after `b`, and zero if `a` and `b` are equal.
@@ -179,7 +179,7 @@ This method parses a string and returns a usable JavaScript object.
Given the following JSON string, how would you convert it back into a JavaScript object and access the `"age"` value?
```js
const jsonString = '{"name": "Alice", "age": 25}';
const jsonString = '{"name":"Alice","age":25}';
```
## --answers--
@@ -82,7 +82,7 @@ const [first, second, ...rest] = fruits;
console.log(first); // "apple"
console.log(second); // "banana"
console.log(rest); // ["orange","mango","kiwi"]
console.log(rest); // ["orange", "mango", "kiwi"]
```
## Common Array Methods
@@ -187,14 +187,14 @@ console.log(shallowCopiedArray); // [1, 2, 3, 4]
const str = "hello";
const charArray = str.split("");
console.log(charArray); // ["h","e","l","l","o"]
console.log(charArray); // ["h", "e", "l", "l", "o"]
```
- **`reverse()` Method**: This method reverses an array in place.
```js
const desserts = ["cake", "cookies", "pie"];
console.log(desserts.reverse()); // ["pie","cookies","cake"]
console.log(desserts.reverse()); // ["pie", "cookies", "cake"]
```
- **`join()` Method**: This method concatenates all the elements of an array into a single string, with each element separated by a specified separator. If no separator is provided, or an empty string (`""`) is used, the elements will be joined without any separator.
@@ -49,8 +49,8 @@ console.log(doubledNumbers); // [2, 4, 6, 8, 10]
const numbers = [1, 2, 3, 4, 5];
const doubled = numbers.map((num) => num * 2);
console.log(numbers); // [1,2,3,4,5]
console.log(doubled); // [2,4,6,8,10]
console.log(numbers); // [1, 2, 3, 4, 5]
console.log(doubled); // [2, 4, 6, 8, 10]
```
- **`filter()` Method**: This method is used to create a new array with elements that pass a specified test, making it useful for selectively extracting items based on criteria. Just like the `map` method, the callback function for the `filter` method accepts the same three arguments: the current element being processed, the index, and the array.
@@ -95,7 +95,7 @@ console.log(result); // "hello, JavaScript!"
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort();
console.log(fruits); // ["Apple","Banana","Mango","Orange"]
console.log(fruits); // ["Apple", "Banana", "Mango", "Orange"]
```
If you need to sort numbers, then you will need to pass in a compare function. The `sort` method converts the elements to strings and then compares their sequences of UTF-16 code units values. UTF-16 code units are the numeric values that represent the characters in the string. Examples of UTF-16 code units are the numbers 65, 66, and 67 which represent the characters "A", "B", and "C" respectively. So the number 200 appears before the number 3 in an array, because the string "200" comes before the string "3" when comparing their UTF-16 code units.
@@ -133,7 +133,7 @@ const text = " Hello, world! ";
console.log(text.trimEnd()); // " Hello, world!"
```
- **The `prompt()` Method**: This method of thw `window` is used to get information from a user through the form of a dialog box. This method takes two arguments. The first argument is the message which will appear inside the dialog box, typically prompting the user to enter information. The second one is a default value which is optional and will fill the input field initially.
- **The `prompt()` Method**: This method of the `window` is used to get information from a user through the form of a dialog box. This method takes two arguments. The first argument is the message which will appear inside the dialog box, typically prompting the user to enter information. The second one is a default value which is optional and will fill the input field initially.
```js
const answer = window.prompt("What's your favorite animal?"); // This will change depending on what the user answers
@@ -335,7 +335,7 @@ const text = " Hello, world! ";
console.log(text.trimEnd()); // " Hello, world!"
```
- **The `prompt()` Method**: This method of thw `window` is used to get information from a user through the form of a dialog box. This method takes two arguments. The first argument is the message which will appear inside the dialog box, typically prompting the user to enter information. The second one is a default value which is optional and will fill the input field initially.
- **The `prompt()` Method**: This method of the `window` is used to get information from a user through the form of a dialog box. This method takes two arguments. The first argument is the message which will appear inside the dialog box, typically prompting the user to enter information. The second one is a default value which is optional and will fill the input field initially.
```js
const answer = window.prompt("What's your favorite animal?"); // This will change depending on what the user answers
@@ -745,7 +745,7 @@ const [first, second, ...rest] = fruits;
console.log(first); // "apple"
console.log(second); // "banana"
console.log(rest); // ["orange","mango","kiwi"]
console.log(rest); // ["orange", "mango", "kiwi"]
```
## Common Array Methods
@@ -850,14 +850,14 @@ console.log(shallowCopiedArray); // [1, 2, 3, 4]
const str = "hello";
const charArray = str.split("");
console.log(charArray); // ["h","e","l","l","o"]
console.log(charArray); // ["h", "e", "l", "l", "o"]
```
- **`reverse()` Method**: This method reverses an array in place.
```js
const desserts = ["cake", "cookies", "pie"];
console.log(desserts.reverse()); // ["pie","cookies","cake"]
console.log(desserts.reverse()); // ["pie", "cookies", "cake"]
```
- **`join()` Method**: This method concatenates all the elements of an array into a single string, with each element separated by a specified separator. If no separator is provided, or an empty string (`""`) is used, the elements will be joined without any separator.
@@ -1379,8 +1379,8 @@ console.log(doubledNumbers); // [2, 4, 6, 8, 10]
const numbers = [1, 2, 3, 4, 5];
const doubled = numbers.map((num) => num * 2);
console.log(numbers); // [1,2,3,4,5]
console.log(doubled); // [2,4,6,8,10]
console.log(numbers); // [1, 2, 3, 4, 5]
console.log(doubled); // [2, 4, 6, 8, 10]
```
- **`filter()` Method**: This method is used to create a new array with elements that pass a specified test, making it useful for selectively extracting items based on criteria. Just like the `map` method, the callback function for the `filter` method accepts the same three arguments: the current element being processed, the index, and the array.
@@ -1425,7 +1425,7 @@ console.log(result); // "hello, JavaScript!"
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort();
console.log(fruits); // ["Apple","Banana","Mango","Orange"]
console.log(fruits); // ["Apple", "Banana", "Mango", "Orange"]
```
If you need to sort numbers, then you will need to pass in a compare function. The `sort` method converts the elements to strings and then compares their sequences of UTF-16 code units values. UTF-16 code units are the numeric values that represent the characters in the string. Examples of UTF-16 code units are the numbers 65, 66, and 67 which represent the characters "A", "B", and "C" respectively. So the number 200 appears before the number 3 in an array, because the string "200" comes before the string "3" when comparing their UTF-16 code units.