Skip to content

Commit f86d88b

Browse files
authored
feat: add faqs section
1 parent 943ba15 commit f86d88b

File tree

1 file changed

+247
-1
lines changed

1 file changed

+247
-1
lines changed

README.md

Lines changed: 247 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,21 @@ Create a Pull Request so that the TAs can check your work.
7777
1.4 Print `"The navigator's name is YYYY"`.
7878

7979
### Iteration 2: Conditionals
80+
8081
2.1. Depending on which name [is longer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length), print:
8182
<br>
8283
- `The driver has the longest name, it has XX characters.` or <br>
8384
- `It seems that the navigator has the longest name, it has XX characters.` or <br>
8485
- `Wow, you both have equally long names, XX characters!`.
8586

8687
### Iteration 3: Loops
88+
8789
3.1 Print the characters of the driver's name, separated by space, and [in capital letters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase), i.e., `"J O H N"`.
8890

8991
3.2 Print all the characters of the navigator's name, in reverse order, i.e., `"nhoJ"`.
9092

9193
3.3 Depending on the [lexicographic order](https://en.wikipedia.org/wiki/Lexicographical_order) of the strings, print: <br>
94+
9295
- `The driver's name goes first.` <br>
9396
- `Yo, the navigator goes first definitely.` <br>
9497
- `What?! You both have the same name?`
@@ -98,12 +101,15 @@ Create a Pull Request so that the TAs can check your work.
98101
#### Bonus 1:
99102

100103
Go to the [lorem ipsum generator](http://www.lipsum.com/) website and:
104+
101105
- Generate 3 paragraphs. Store the text in a new string variable named `longText`.
102106
- Make your program count the number of words in the string.
103107
- Make your program count the number of times the Latin word [`et`](https://en.wiktionary.org/wiki/et#Latin) appears.
104108

105109
#### Bonus 2:
110+
106111
Create a new variable `phraseToCheck` and have it contain some string value. Write a code that will check if the value we assigned to this variable is a [Palindrome](https://en.wikipedia.org/wiki/Palindrome). Here are some examples of palindromes:
112+
107113
- "A man, a plan, a canal, Panama!"
108114
- "Amor, Roma"
109115
- "race car"
@@ -115,6 +121,12 @@ Create a new variable `phraseToCheck` and have it contain some string value. Wri
115121

116122
__IMPORTANT__: If you use Google to help you to find solution to this iteration, you might run into some advanced solutions that use string or array methods (such as _join()_, _reverse()_, etc.). However, we want you to apply the knowledge you currently have and try to come up with a solution by just using `for` loop and `if-else` statements with some `break` and `continue`.
117123

124+
125+
126+
__Happy coding!__ :heart:
127+
128+
129+
118130
## Extra Resources
119131

120132
- [String - MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)
@@ -124,5 +136,239 @@ Create a new variable `phraseToCheck` and have it contain some string value. Wri
124136

125137
<br>
126138

127-
__Happy coding!__ :heart:
139+
140+
141+
## FAQs
142+
143+
144+
145+
<details>
146+
<summary>I am stuck in the exercise and don't know how to solve the problem or where to start.</summary>
147+
<br>
148+
149+
If you are stuck in your code and don't know how to solve the problem or where to start, you should take a step back and try to form a clear question about the specific issue you are facing. This will help you narrow down the problem and come up with potential solutions.
150+
151+
152+
For example, is it a concept that you don't understand, or are you receiving an error message that you don't know how to fix? It is usually helpful to try to state the problem as clearly as possible, including any error messages you are receiving. This can help you communicate the issue to others and potentially get help from classmates or online resources.
153+
154+
155+
Once you have a clear understanding of the problem, you will be able to start working towards the solution.
156+
157+
[Back to top](#faqs)
158+
</details>
159+
160+
161+
162+
<details>
163+
<summary>How do you find a length of a string in JavaScript?</summary>
164+
<br>
165+
166+
To find the length of a string use the `length` property. Here is an example:
167+
168+
```js
169+
const str = "Hello, world!"";
170+
console.log(str.length); // 13
171+
```
172+
173+
The `length` property returns the number of characters in the string, including spaces and special characters.
174+
175+
176+
177+
[Back to top](#faqs)
178+
</details>
179+
180+
181+
182+
183+
184+
<details>
185+
<summary>How do I loop over a string?</summary>
186+
<br>
187+
188+
Here is an example of using a `for` loop to loop over a string:
189+
190+
```js
191+
let str = "ironhack";
192+
193+
for (let i = 0; i < str.length; i++) {
194+
console.log(str[i]);
195+
}
196+
```
197+
198+
This code will iterate over each character in the `str` string. The loop will run for as many iterations as there are characters in the string.
199+
200+
On each iteration, the loop will log the current character to the console.
201+
202+
203+
204+
[Back to top](#faqs)
205+
</details>
206+
207+
208+
209+
<details>
210+
<summary>How do I check if substring exists in a given string?</summary>
211+
<br>
212+
213+
You can use the `includes()` method to check if a substring exists in a given string.
214+
215+
This method returns a boolean value (`true` or `false`) indicating whether the string it is called on includes the substring specified as an argument.
216+
217+
Example:
218+
219+
```js
220+
let str = "hello world";
221+
222+
console.log(str.includes("hello")); // true
223+
console.log(str.includes("world")); // true
224+
console.log(str.includes("bye")); // false
225+
```
226+
227+
<br>
228+
229+
230+
231+
You can also use the `indexOf()` method, which returns the index of the first occurrence of the substring within the string, or -1 if the substring is not found.
232+
233+
Example:
234+
235+
```js
236+
let str = "hello world";
237+
238+
console.log(str.indexOf("h")); // 0
239+
console.log(str.indexOf("world")); // 6
240+
console.log(str.indexOf("bye")); // -1
241+
```
242+
243+
244+
245+
[Back to top](#faqs)
246+
</details>
247+
248+
249+
250+
251+
252+
<details>
253+
<summary>How do I convert a string to capital or lowercase letters?</summary>
254+
<br>
255+
256+
##### Uppercase
257+
258+
To convert a string to *uppercase* letters, use the `toUpperCase()` method. The method `toUpperCase()` returns a new string with all the characters in uppercase.
259+
260+
Example:
261+
262+
```js
263+
let str = "ironhack";
264+
265+
console.log(str.toUpperCase()); // "IRONHACK"
266+
```
267+
268+
<br>
269+
270+
271+
272+
##### Lowercase
273+
274+
To convert a string to all *lowercase* letters, you can use the `toLowerCase()` method. This method returns a new string with all the characters in lowercase.
275+
276+
Example:
277+
278+
```js
279+
let str = "IRONHACK";
280+
281+
console.log(str.toLowerCase()); // "ironhack"
282+
```
283+
284+
It's important to note that methods `toUpperCase()` and `toLowerCase()` do not modify the original string. They return a new string that has been converted to the desired case.
285+
286+
287+
288+
[Back to top](#faqs)
289+
</details>
290+
291+
292+
293+
294+
295+
<details>
296+
<summary>How do I reverse a string?</summary>
297+
<br>
298+
299+
You can use a `for` loop to iterate over the characters of the string and add them to a new string in reverse order.
300+
301+
Example:
302+
303+
```js
304+
let str = "drawer";
305+
let reversed = "";
306+
307+
for (let i = str.length - 1; i >= 0; i--) {
308+
reversed += str[i];
309+
}
310+
311+
console.log(reversed); // "reward"
312+
```
313+
314+
The above example, uses a `for` loop to iterate over the characters of the `str` string in reverse order, starting at the last character and ending at the first character. On each iteration, it adds the current character to the `reversed` string.
315+
316+
317+
318+
[Back to top](#faqs)
319+
</details>
320+
321+
322+
323+
<details>
324+
<summary>How do I create a multo-line string in JavaScript?</summary>
325+
<br>
326+
327+
To create a multi-line string in JavaScript, you must use template literals. Template literals are string literals denoted with backticks (`). They allow you to embed expressions inside string values and create strings that span multiple lines.
328+
329+
Example:
330+
331+
```js
332+
let str = `This is an
333+
example of a
334+
multi-line string.`;
335+
336+
console.log(str);
337+
```
338+
339+
340+
341+
[Back to top](#faqs)
342+
</details>
343+
344+
345+
346+
<details>
347+
<summary>I am unable to push changes to the repository. What should I do?</summary>
348+
<br>
349+
350+
There are a couple of possible reasons why you may be unable to *push* changes to a Git repository:
351+
352+
1. **You have not committed your changes:** Before you can push your changes to the repository, you need to commit them using the `git commit` command. Make sure you have committed your changes and try pushing again. To do this, run the following terminal commands from the project folder:
353+
354+
```bash
355+
git add .
356+
git commit -m "Your commit message"
357+
git push
358+
```
359+
360+
361+
2. **You do not have permission to push to the repository:** If you have cloned the repository directly from the main Ironhack repository without making a *Fork* first, you do not have write access to the repository.
362+
To check which remote repository you have cloned, run the following terminal command from the project folder:
363+
364+
```bash
365+
git remote -v
366+
```
367+
368+
If the link shown is the same as the main Ironhack repository, you will need to fork the repository to your Github account first, and then clone your fork to your local machine to be able to push the changes.
369+
370+
Note: You may want to make a copy of the code your have locally, to avoid losing it in the process.
371+
372+
[Back to top](#faqs)
373+
</details>
128374

0 commit comments

Comments
 (0)