fix(guide): simplify directory structure

This commit is contained in:
Mrugesh Mohapatra
2018-10-16 21:26:13 +05:30
parent f989c28c52
commit da0df12ab7
35752 changed files with 0 additions and 317652 deletions

View File

@@ -0,0 +1,22 @@
---
title: Catch Arguments Passed in the Wrong Order When Calling a Function
localeTitle: 调用函数时捕获以错误顺序传递的参数
---
## 调用函数时捕获以错误顺序传递的参数
```javascript
function raiseToPower(b, e) {
return Math.pow(b, e);
}
```
* 上述函数用于将基数`b`提高到指数`e`的幂。
* 必须使用正确顺序的变量专门调用该函数。否则,该函数将混合两个变量并返回不需要的答案。
* 确保可变`power`正确实现`raiseToPower`功能。
## 解:
```javascript
let power = raiseToPower(base, exp);
```

View File

@@ -0,0 +1,15 @@
---
title: Catch Missing Open and Closing Parenthesis After a Function Call
localeTitle: 在函数调用后捕获缺失的打开和关闭括号
---
## 在函数调用后捕获缺失的打开和关闭括号
* 请记住在调用函数时添加左括号和右括号。
* FunctionName +;
## 解:
```javascript
let result = getNine();
```

View File

@@ -0,0 +1,27 @@
---
title: Catch Misspelled Variable and Function Names
localeTitle: 捕获拼错的变量和函数名称
---
## 捕获拼错的变量和函数名称
### 问题解释:
修复代码中的两个拼写错误以便netWorkingCapital计算有效。
### 暗示
检查前两个变量的拼写是否与使用时相对应。
## 扰流板警报!
**提前解决!**
```javascript
// 'i' and 'e' swapped in "receivables" and missing 's' in "payables"
let receivables = 10;
let payables = 8;
let netWorkingCapital = receivables - payables;
console.log(`Net working capital is: ${netWorkingCapital}`);
```

View File

@@ -0,0 +1,17 @@
---
title: Catch Mixed Usage of Single and Double Quotes
localeTitle: 抓住单引号和双引号的混合使用
---
## 抓住单引号和双引号的混合使用
* 请记住,您是选择使用单引号还是双引号,只需在字符前添加`\`即可使字符适合字符串而不关闭单引号或双引号。
* 测试用例只能使用双引号传递。
## 解:
```javascript
//Solution1:
let innerHtml = "<p>Click here to <a href=\"#Home\">return home</a></p>";
console.log(innerHtml);
```

View File

@@ -0,0 +1,70 @@
---
title: Catch Off By One Errors When Using Indexing
localeTitle: 使用索引时捕获一个错误
---
## 使用索引时捕获一个错误
### 基本
由于JavaScript索引的工作方式`firstFive`有**五个元素,**但它们的索引从**0到4**
```javascript
console.log(len); // 5
console.log(firstFive[0]); // 1
/**/
console.log(firstFive[4]); // 5
console.log(firstFive[5]); // undefined
```
这应该足以让你掌握`firstFive`的限制。引导你注意循环。它有什么作用?您可以尝试调试它以找出答案!
### 调试
你得到这个代码:
```javascript
for (let i = 1; i <= len; i++) {
console.log(firstFive[i]);
}
```
要调试这段代码,请使用`console.clear()` 。什么是最好的地方?答案就在`for`声明之前!
```javascript
console.clear();
for (let i = 1; i <= len; i++) {
console.log(firstFive[i]);
}
```
控制台输出:
```text
Console was cleared.
2
3
4
5
undefined
```
### 分析
检查输出。在这些条件下循环首先打印位于1 ...的元素即2它还尝试打印`undefined`索引为5的元素。
这可以被视为这一挑战的关键。保持`console.log()``console.clear()`存在。它们将帮助您了解代码的工作原理。
### 解
解决此问题的最直接方法是更改for条件。 让`i`从0开始。另外 **不**应该为i == 5执行循环。换句话说当i == 5时 `i``len`之间的关系应该是`false` 。这可以通过使用`i < len`来实现是5 <lenfalse循环不会被执行!)。
```javascript
for (let i = 0; i < len; i++) {
```
**快乐的编码!** 电脑
### 资源
* [对于FreeCodeCamp的陈述挑战](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-for-loops)
* [适用于MDN Web文档的声明](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#for_statement)

View File

@@ -0,0 +1,34 @@
---
title: Catch Unclosed Parentheses, Brackets, Braces and Quotes
localeTitle: 抓住未封闭的圆括号,括号,括号和引号
---
## 抓住未封闭的圆括号,括号,括号和引号
reduce方法将数组减少为单个值。如果您不熟悉它以下代码显示了使用该方法的示例
```
const array1 = [1, 2, 3, 4];
console.log(array1.reduce((accumulator, currentValue) => accumulator + currentValue)); // expected output: 10
```
您还可以将reduce方法的参数定义为变量或常量并将其移交给函数例如
```
const array1 = [1, 2, 3, 4];
const reducer = (accumulator, currentValue) => accumulator + currentValue;
// 1 + 2 + 3 + 4
console.log(array1.reduce(reducer)); // expected output: 10
// 5 + 1 + 2 + 3 + 4
console.log(array1.reduce(reducer, 5)); // expected output: 15
```
您可以在[Array.prototype.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce)查看并运行此代码。
## 解:
```javascript
let myArray = [1, 2, 3];
let arraySum = myArray.reduce((previous, current) => previous + current);
console.log(`Sum of array values is: ${arraySum}`);
```

View File

@@ -0,0 +1,25 @@
---
title: Catch Use of Assignment Operator Instead of Equality Operator
localeTitle: 捕获使用赋值运算符而不是等式运算符
---
## 捕获使用赋值运算符而不是等式运算符
* 在这个挑战中只能编辑if语句。
* `=`运算符本身仅用于赋值,而不是用于比较它们。
## 解
```javascript
let x = 7;
let y = 9;
let result = "to come";
if(x == y) {
result = "Equal!";
} else {
result = "Not equal!";
}
console.log(result);
```

View File

@@ -0,0 +1,11 @@
---
title: Debugging
localeTitle: 调试
---
## 调试
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/mathematics/quadratic-equations/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。
#### 更多信息:

View File

@@ -0,0 +1,31 @@
---
title: Prevent Infinite Loops with a Valid Terminal Condition
localeTitle: 使用有效的终端条件防止无限循环
---
## 使用有效的终端条件防止无限循环
* 为防止无限循环, `while-condition`必须达到终止条件才能退出循环。
* 所以这个挑战中的错误是由于for循环中的条件 - `i != 4` - 而发生的。
* 如果你仔细看看代码:
```javascript
function myFunc() {
for (let i = 1; i != 4; i += 2) {
console.log("Still going!");
}
}
```
* 您将看到`i`首先初始化为1并且在循环的每次迭代之后 `i`递增2。
* 使用该逻辑,在第一次迭代之后 - `i = 3`并且第二次迭代`i = 5` ,将永远不满足条件`i != 4`并且将发生无限循环。
## 解:
```javascript
function myFunc() {
for (let i = 1; i <= 4; i += 2) {
console.log("Still going!");
}
}
```

View File

@@ -0,0 +1,9 @@
---
title: Understanding the Differences between the freeCodeCamp and Browser Console
localeTitle: 了解freeCodeCamp和浏览器控制台之间的差异
---
## 了解freeCodeCamp和浏览器控制台之间的差异
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。

View File

@@ -0,0 +1,51 @@
---
title: Use Caution When Reinitializing Variables Inside a Loop
localeTitle: 在循环内重新初始化变量时请小心
---
## 在循环内重新初始化变量时请小心
* 必须通过重新定义`row[]`的范围来解决这一挑战。
* 以下是所需矩阵的示例。
```javascript
[
[0][0],
[0][0],
[0][0]
]
```
* 然而,当前的矩阵 - 见下文 - 远离所需的矩阵
```javascript
[
[0][0][0][0][0][0],
[0][0][0][0][0][0],
[0][0][0][0][0][0]
]
```
* 由于`row[]`数组被声明为嵌套for循环之外的全局变量因此发生此错误。
* 但是,要正确填充矩阵,必须在每次外部循环迭代后重置`row[]`数组。
## 解
```javascript
function zeroArray(m, n) {
let newArray = [];
for (let i = 0; i < m; i++) {
let row = []; /* <----- row has been declared inside the outer loop.
Now a new row will be initialised during each iteration of the outer loop allowing
for the desired matrix. */
for (let j = 0; j < n; j++) {
row.push(0);
}
newArray.push(row);
}
return newArray;
}
let matrix = zeroArray(3, 2);
console.log(matrix);
```

View File

@@ -0,0 +1,9 @@
---
title: Use the JavaScript Console to Check the Value of a Variable
localeTitle: 使用JavaScript控制台检查变量的值
---
## 使用JavaScript控制台检查变量的值
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/debugging/use-the-javascript-console-to-check-the-value-of-a-variable/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。

View File

@@ -0,0 +1,15 @@
---
title: Use typeof to Check the Type of a Variable
localeTitle: 使用typeof检查变量的类型
---
## 使用typeof检查变量的类型
* 使用`console.log(typeof variable)`显示所需变量的类型。
## 解:
```javascript
console.log(typeof seven);
console.log(typeof three);
```