Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2c12e6c

Browse files
committed
Edit copy
1 parent 48725fa commit 2c12e6c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

‎README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ console.log(even_or_odd(-3)); // 'Odd'
5959

6060
```js
6161
const even_or_odd = number => {
62+
// Let's use a ternary operator
6263
return number % 2 === 0 ? 'Even' : 'Odd';
6364
};
6465
```
@@ -71,7 +72,7 @@ const even_or_odd = number => {
7172

7273
## 3. Clock
7374

74-
The clock shows h hours (0 <= h <= 23), m minutes (0 <= m <= 59) and s seconds (0 <= s <= 59) after midnight. Your task is to write a function which returns the time since midnight in milliseconds.
75+
The clock shows h hours (0 <= h <= 23), m minutes (0 <= m <= 59) and s seconds (0 <= s <= 59) after midnight. Your task is to write a function which returns the time since midnight in milliseconds. There are 1,000 milliseconds in a second.
7576

7677
```js
7778
const past = (h, m, s) => {
@@ -116,6 +117,7 @@ console.log(greet('Sara')); // "Hello, Sara how are you doing today?"
116117

117118
```js
118119
const greet = name => {
120+
// Let's use a template literal
119121
return `Hello, ${name} how are you doing today?`;
120122
};
121123
```
@@ -158,7 +160,7 @@ const century = year => {
158160

159161
## 6. Keep Hydrated!
160162

161-
Nathan loves cycling. Because Nathan knows it is important to stay hydrated, he drinks 0.5 litres of water per hour of cycling. You get given the time in hours and you need to return the number of litres Nathan will drink, rounded to the smallest value.
163+
Nathan loves cycling. Because Nathan knows it is important to stay hydrated, he drinks 0.5 litres of water per hour of cycling. Given the time in hours, you need to return the number of litres of water that Nathan will drink, rounded to the smallest value.
162164

163165
```js
164166
const litres = time => {
@@ -178,7 +180,7 @@ console.log(litres(1787)); // 893
178180

179181
```js
180182
const litres = time => {
181-
return Math.floor(time /2);
183+
return Math.floor(time *0.5);
182184
};
183185
```
184186

@@ -242,6 +244,13 @@ const getCount = str => {
242244
}
243245
return vowelsCount;
244246
};
247+
248+
// An alternative solution could be to convert the string to an array (using the spread syntax)
249+
// and filtering that array by vowels
250+
const getCount = str => {
251+
const arr = [...str];
252+
return arr.filter(ele => ['a', 'e', 'i', 'o', 'u'].includes(ele)).length;
253+
};
245254
```
246255

247256
</details>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /