Skip to content

Commit 04f90c8

Browse files
committed
day 12
1 parent 29bb42d commit 04f90c8

File tree

1 file changed

+62
-39
lines changed

1 file changed

+62
-39
lines changed

12_Day/12_day_regular_expressions.md

Lines changed: 62 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -426,40 +426,6 @@ console.log(result) // true
426426
### Exercises: Level 1
427427

428428
1. Calculate the total annual income of the person from the following text. ‘He earns 4000 euro from salary per month, 10000 euro annual bonus, 5500 euro online courses per month.’
429-
430-
### Exercises: Level 2
431-
432-
1. What is the most frequent word in the following paragraph ?
433-
434-
```js
435-
paragraph = 'I love teaching. If you do not love teaching what else can you love. I love Python if you do not love something which can give you all the capabilities to develop an application what else can you love.
436-
```
437-
438-
```sh
439-
[(6, 'love'),
440-
(5, 'you'),
441-
(3, 'can'),
442-
(2, 'what'),
443-
(2, 'teaching'),
444-
(2, 'not'),
445-
(2, 'else'),
446-
(2, 'do'),
447-
(2, 'I'),
448-
(1, 'which'),
449-
(1, 'to'),
450-
(1, 'the'),
451-
(1, 'something'),
452-
(1, 'if'),
453-
(1, 'give'),
454-
(1, 'develop'),
455-
(1, 'capabilities'),
456-
(1, 'application'),
457-
(1, 'an'),
458-
(1, 'all'),
459-
(1, 'Python'),
460-
(1, 'If')]
461-
```
462-
463429
1. The position of some particles on the horizontal x-axis -12, -4, -3 and -1 in the negative direction, 0 at origin, 4 and 8 in the positive direction. Extract these numbers and find the distance between the two furthest particles.
464430

465431
```js
@@ -477,24 +443,81 @@ distance = 12
477443
is_valid_variable('firstname') # True
478444
```
479445

446+
### Exercises: Level 2
447+
448+
1. Write a function called *tenMostFrequentWords* which get the ten most frequent word from a string?
449+
450+
```js
451+
paragraph = `I love teaching. If you do not love teaching what else can you love. I love Python if you do not love something which can give you all the capabilities to develop an application what else can you love.`
452+
console.log(tenMostFrequentWords(paragraph))
453+
```
454+
455+
```sh
456+
[(6, 'love'),
457+
(5, 'you'),
458+
(3, 'can'),
459+
(2, 'what'),
460+
(2, 'teaching'),
461+
(2, 'not'),
462+
(2, 'else'),
463+
(2, 'do'),
464+
(2, 'I'),
465+
(1, 'which'),
466+
(1, 'to'),
467+
(1, 'the'),
468+
(1, 'something'),
469+
(1, 'if'),
470+
(1, 'give'),
471+
(1, 'develop'),
472+
(1, 'capabilities'),
473+
(1, 'application'),
474+
(1, 'an'),
475+
(1, 'all'),
476+
(1, 'Python'),
477+
(1, 'If')
478+
]
479+
```
480+
481+
```js
482+
console.log(tenMostFrequentWords(paragraph, 10))
483+
```
484+
485+
```sh
486+
[ (6, 'love'),
487+
(5, 'you'),
488+
(3, 'can'),
489+
(2, 'what'),
490+
(2, 'teaching'),
491+
(2, 'not'),
492+
(2, 'else'),
493+
(2, 'do'),
494+
(2, 'I'),
495+
(1, 'which')
496+
]
497+
```
498+
480499
### Exercises: Level 3
481500

482501
1. Writ a function which cleans text. Clean the following text. After cleaning, count three most frequent words in the string.
483502

484503
```js
485-
sentence = '''%I $am@% a %tea@cher%, &and& I lo%#ve %tea@ching%;. There $is nothing; &as& mo@re rewarding as educa@ting &and& @emp%o@wering peo@ple. ;I found tea@ching m%o@re interesting tha@n any other %jo@bs. %Do@es thi%s mo@tivate yo@u to be a tea@cher!?'''
504+
sentence = `%I $am@% a %tea@cher%, &and& I lo%#ve %tea@ching%;. There $is nothing; &as& mo@re rewarding as educa@ting &and& @emp%o@wering peo@ple. ;I found tea@ching m%o@re interesting tha@n any other %jo@bs. %Do@es thi%s mo@tivate yo@u to be a tea@cher!?`
486505

487506
console.log(cleanText(sentence))
507+
```
488508
509+
```sh
489510
I am a teacher and I love teaching There is nothing as more rewarding as educating and empowering people I found teaching more interesting than any other jobs Does this motivate you to be a teacher
490511
```
491512
1. Write a function which find the most frequent words. After cleaning, count three most frequent words in the string.
492513
493-
```js
494-
console.log(mostFrequentWords(cleaned_text))
495-
[(3, 'I'), (2, 'teaching'), (2, 'teacher')]
496-
```
514+
```js
515+
console.log(mostFrequentWords(cleanedText))
516+
[(3, 'I'), (2, 'teaching'), (2, 'teacher')]
517+
```
518+
497519
498520
🎉 CONGRATULATIONS ! 🎉
499521
522+
500523
[<< Day 11](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/11_Day/11_day_destructuring_and_spread.md) | [Day 13>>](#)

0 commit comments

Comments
 (0)