fix(guide): Added solutions and some hints and problem explanations for curriculum related Guide articles being ported over to forum (#36545)

* fix: added info and solutions for stubs

* fix: made title match main header

* fix: removed wrong closing tag

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: added closing tag

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: corrected solution

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: changed verbiage

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: added code tags

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: added solution
This commit is contained in:
Randell Dawson
2019-08-01 05:16:54 -07:00
committed by Oliver Eyton-Williams
parent af1071c518
commit 7164d9a797
56 changed files with 1752 additions and 139 deletions

View File

@@ -1,7 +1,7 @@
---
title: Comparison with the greater than operator (>)
title: Comparison with the Greater Than Operator
---
# Comparison with the Greater Than Operator (>)
# Comparison with the Greater Than Operator
---

View File

@@ -1,7 +1,7 @@
---
title: Comparisons with the && (logical AND) operator
title: Comparisons with the Logical AND operator
---
# Comparisons with the && (logical AND) operator
# Comparisons with the Logical AND operator
---
## Problem Explanation

View File

@@ -3,7 +3,37 @@ title: Iterate with JavaScript For Loops
---
# Iterate with JavaScript For Loops
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-for-loops/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
---
## Hints
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
### Hint 1
```javascript
for(var i = 0; i < 5; i++) { // There are 3 parts here
```
There are three parts to for loop. They are separated by semicolons.
1. The initialization: `var i = 0;` - This code runs only once at the start of the loop. It's usually used to declare the counter variable (with `var`) and initialize the counter (in this case it is set to 0).
2. The condition: `i < 5;` - The loop will run as long as this is `true`. That means that as soon as `i` is equal to 5, the loop will stop looping. Note that the inside of the loop will never see `i` as 5 because it will stop before then. If this condition is initially `false`, the loop will never execute.
3. The increment: `i++` - This code is run at the end of each loop. It's usually a simple increment (`++` operator), but can really be any expression. It is used to move the counter (`i`) forward (or backwards, or whatever).
---
## Solutions
<details><summary>Solution 1 (Click to Show/Hide)</summary>
```javascript
var ourArray = [];
for (var i = 0; i < 5; i++) {
ourArray.push(i);
}
var myArray = [];
for (var i = 1; i < 6; i++) {
myArray.push(i);
}
```
</details>

View File

@@ -3,7 +3,27 @@ title: Logical Order in If Else Statements
---
# Logical Order in If Else Statements
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/basic-javascript/logical-order-in-if-else-statements/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
---
## Hints
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
### Hint 1
So be careful while using the `if`, `else if` and `else` statements and always remember that these are executed from top to bottom. Keep this in mind placing your statements accordingly so that you get the desired output.
---
## Solutions
<details><summary>Solution 1 (Click to Show/Hide)</summary>
```javascript
function orderMyLogic(val) {
if(val < 5) {
return "Less than 5";
} else if (val < 10) {
return "Less than 10";
} else {
return "Greater than or equal to 10";
}
}
```
</details>

View File

@@ -3,7 +3,27 @@ title: Quoting Strings with Single Quotes
---
# Quoting Strings with Single Quotes
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/basic-javascript/quoting-strings-with-single-quotes/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
---
## Problem Explanation
String values in JavaScript may be written with single or double quotes, so long as you start and end with the same type of quote. Unlike some languages, single and double quotes are functionally identical in JavaScript.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
```
"This string has \"double quotes\" in it"
```
The value in using one or the other has to do with the need to escape quotes of the same type. If you have a string with many double quotes, this can be difficult to read and write. Instead, use single quotes:
```
'This string has "double quotes" in it. And "probably" lots of them.'
```
---
## Solutions
<details><summary>Solution 1 (Click to Show/Hide)</summary>
```javascript
var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';
```
</details>