Skip to content

Commit e90d618

Browse files
Bob approaches prettierfied (#2018)
* Update introduction.md * Update introduction.md * Update content.md * Update content.md * Update content.md * Update content.md * Update content.md * [CI] Format code Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent c112f04 commit e90d618

4 files changed

Lines changed: 40 additions & 20 deletions

File tree

exercises/practice/bob/.approaches/answer-array/content.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ const answers = [
1010

1111
export function hey(message) {
1212
const speech = message.trimEnd();
13-
if (speech == '') return 'Fine. Be that way!';
13+
if (speech == '') {
14+
return 'Fine. Be that way!';
15+
}
1416

1517
const isQuestion = speech.endsWith('?') ? 1 : 0;
1618
const isShout =
@@ -54,12 +56,14 @@ For example, giving a question a score of `1` would use an index of `1` to get t
5456

5557
## Shortening
5658

57-
Notice that when the body of an `if` statement is a short single line, both the test expression and the body could be put on the same line, like so
59+
Note that when the body of an `if` statement is a short single line, both the test expression and the body could be put on the same line, like so
5860

5961
```javascript
6062
if (speech == '') return 'Fine. Be that way!';
6163
```
6264

65+
It may not comply with some coding styles, but your team preferences may allow it.
66+
6367
[string]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
6468
[trimend]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd
6569
[regex]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions

exercises/practice/bob/.approaches/if-statements/content.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33
```javascript
44
export function hey(message) {
55
const speech = message.trimEnd();
6-
if (speech == '') return 'Fine. Be that way!';
6+
if (speech == "") {
7+
return "Fine. Be that way!";
8+
}
79

8-
const isQuestion = speech.endsWith('?');
10+
const isQuestion = speech.endsWith("?");
911
const isShout = /[A-Z]{1}/.test(speech) && speech == speech.toUpperCase();
1012

11-
if (isShout)
13+
if (isShout) {
1214
return isQuestion
1315
? "Calm down, I know what I'm doing!"
14-
: 'Whoa, chill out!';
15-
if (isQuestion) return 'Sure.';
16-
return 'Whatever.';
17-
}
16+
: "Whoa, chill out!";
17+
}
18+
if (isQuestion) {
19+
return "Sure.";
20+
}
21+
return "Whatever.";
1822
```
1923
2024
In this approach you have a series of `if` statements using the private methods to evaluate the conditions.
@@ -53,12 +57,14 @@ or only `isShout` is true.
5357
5458
## Shortening
5559
56-
Notice that when the body of an `if` statement is a short single line, both the test expression and the body could be put on the same line, like so
60+
Note that when the body of an `if` statement is a short single line, both the test expression and the body could be put on the same line, like so
5761
5862
```javascript
5963
if (speech == '') return 'Fine. Be that way!';
6064
```
6165
66+
It may not comply with some coding styles, but your team preferences may allow it.
67+
6268
[string]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
6369
[trimend]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd
6470
[endswith]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith

exercises/practice/bob/.approaches/introduction.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,22 @@ Regardless of the approach used, some things you could look out for include
3030
```javascript
3131
export function hey(message) {
3232
const speech = message.trimEnd();
33-
if (speech == '') return 'Fine. Be that way!';
33+
if (speech == "") {
34+
return "Fine. Be that way!";
35+
}
3436

35-
const isQuestion = speech.endsWith('?');
37+
const isQuestion = speech.endsWith("?");
3638
const isShout = /[A-Z]{1}/.test(speech) && speech == speech.toUpperCase();
3739

38-
if (isShout)
40+
if (isShout) {
3941
return isQuestion
4042
? "Calm down, I know what I'm doing!"
41-
: 'Whoa, chill out!';
42-
if (isQuestion) return 'Sure.';
43-
return 'Whatever.';
44-
}
43+
: "Whoa, chill out!";
44+
}
45+
if (isQuestion) {
46+
return "Sure.";
47+
}
48+
return "Whatever.";
4549
```
4650
4751
For more information, check the [`if` statements approach][approach-if].
@@ -51,7 +55,9 @@ For more information, check the [`if` statements approach][approach-if].
5155
```javascript
5256
export function hey(message) {
5357
const speech = message.trim();
54-
if (speech == '') return 'Fine. Be that way!';
58+
if (speech == '') {
59+
return 'Fine. Be that way!';
60+
}
5561

5662
const isQuestion = speech.endsWith('?');
5763
const isShout = /[A-Z]{1}/.test(speech) && speech == speech.toUpperCase();

exercises/practice/bob/.approaches/switch-statement/content.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
```javascript
44
export function hey(message) {
55
const speech = message.trim();
6-
if (speech == '') return 'Fine. Be that way!';
6+
if (speech == '') {
7+
return 'Fine. Be that way!';
8+
}
79

810
const isQuestion = speech.endsWith('?');
911
const isShout = /[A-Z]{1}/.test(speech) && speech == speech.toUpperCase();
@@ -49,12 +51,14 @@ If neither `isQuestion` and `isShout` are `true`, the `default` arm of the `swit
4951

5052
## Shortening
5153

52-
Notice that when the body of an `if` statement is a short single line, both the test expression and the body could be put on the same line, like so
54+
Note that when the body of an `if` statement is a short single line, both the test expression and the body could be put on the same line, like so
5355

5456
```javascript
5557
if (input == '') return 'Fine. Be that way!';
5658
```
5759

60+
It may not comply with some coding styles, but your team preferences may allow it.
61+
5862
[switch]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch
5963
[string]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
6064
[trimend]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd

0 commit comments

Comments
 (0)