You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 12_Day/12_day_regular_expressions.md
+62-39Lines changed: 62 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -426,40 +426,6 @@ console.log(result) // true
426
426
### Exercises: Level 1
427
427
428
428
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
-
463
429
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.
464
430
465
431
```js
@@ -477,24 +443,81 @@ distance = 12
477
443
is_valid_variable('firstname') # True
478
444
```
479
445
446
+
### Exercises: Level 2
447
+
448
+
1. Write a functioncalled*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
+
480
499
### Exercises: Level 3
481
500
482
501
1. Writ a functionwhich cleans text. Clean the following text. After cleaning, count three most frequent words in the string.
483
502
484
503
```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!?`
486
505
487
506
console.log(cleanText(sentence))
507
+
```
488
508
509
+
```sh
489
510
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
490
511
```
491
512
1. Write a functionwhich find the most frequent words. After cleaning, count three most frequent words in the string.
492
513
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
+
497
519
498
520
🎉 CONGRATULATIONS ! 🎉
499
521
522
+
500
523
[<< Day 11](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/11_Day/11_day_destructuring_and_spread.md) | [Day 13>>](#)
0 commit comments