From 57348a559d2a0394db4d42386eac72384c9b6e20 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+KamrulSh@users.noreply.github.com> Date: Wed, 28 Oct 2020 23:26:53 +0600 Subject: [PATCH] fix indentation in exercises --- .../12_day_regular_expressions.md | 148 +++++++++--------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/12_Day_Regular_expressions/12_day_regular_expressions.md b/12_Day_Regular_expressions/12_day_regular_expressions.md index 94e132f..f332847 100644 --- a/12_Day_Regular_expressions/12_day_regular_expressions.md +++ b/12_Day_Regular_expressions/12_day_regular_expressions.md @@ -429,97 +429,97 @@ console.log(result) // true 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.’ 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. -```js -points = ['-1', '2', '-4', '-3', '-1', '0', '4', '8'] -sortedPoints = [-4, -3, -1, -1, 0, 2, 4, 8] -distance = 12 -``` + ```js + points = ['-1', '2', '-4', '-3', '-1', '0', '4', '8'] + sortedPoints = [-4, -3, -1, -1, 0, 2, 4, 8] + distance = 12 + ``` 1. Write a pattern which identify if a string is a valid JavaScript variable -```sh -is_valid_variable('first_name') # True -is_valid_variable('first-name') # False -is_valid_variable('1first_name') # False -is_valid_variable('firstname') # True -``` + ```sh + is_valid_variable('first_name') # True + is_valid_variable('first-name') # False + is_valid_variable('1first_name') # False + is_valid_variable('firstname') # True + ``` ### Exercises: Level 2 1. Write a function called *tenMostFrequentWords* which get the ten most frequent word from a string? -```js -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.` -console.log(tenMostFrequentWords(paragraph)) -``` - -```sh -[ -{word:'love', count:6}, -{word:'you', count:5}, -{word:'can', count:3}, -{word:'what', count:2}, -{word:'teaching', count:2}, -{word:'not', count:2}, -{word:'else', count:2}, -{word:'do', count:2}, -{word:'I', count:2}, -{word:'which', count:1}, -{word:'to', count:1}, -{word:'the', count:1}, -{word:'something', count:1}, -{word:'if', count:1}, -{word:'give', count:1}, -{word:'develop',count:1}, -{word:'capabilities',count:1}, -{word:'application', count:1}, -{word:'an',count:1}, -{word:'all',count:1}, -{word:'Python',count:1}, -{word:'If',count:1}] -``` - -```js -console.log(tenMostFrequentWords(paragraph, 10)) -``` - -```sh -[ -{word:'love', count:6}, -{word:'you', count:5}, -{word:'can', count:3}, -{word:'what', count:2}, -{word:'teaching', count:2}, -{word:'not', count:2}, -{word:'else', count:2}, -{word:'do', count:2}, -{word:'I', count:2}, -{word:'which', count:1} -] -``` + ```js + 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.` + console.log(tenMostFrequentWords(paragraph)) + ``` + + ```sh + [ + {word:'love', count:6}, + {word:'you', count:5}, + {word:'can', count:3}, + {word:'what', count:2}, + {word:'teaching', count:2}, + {word:'not', count:2}, + {word:'else', count:2}, + {word:'do', count:2}, + {word:'I', count:2}, + {word:'which', count:1}, + {word:'to', count:1}, + {word:'the', count:1}, + {word:'something', count:1}, + {word:'if', count:1}, + {word:'give', count:1}, + {word:'develop',count:1}, + {word:'capabilities',count:1}, + {word:'application', count:1}, + {word:'an',count:1}, + {word:'all',count:1}, + {word:'Python',count:1}, + {word:'If',count:1}] + ``` + + ```js + console.log(tenMostFrequentWords(paragraph, 10)) + ``` + + ```sh + [ + {word:'love', count:6}, + {word:'you', count:5}, + {word:'can', count:3}, + {word:'what', count:2}, + {word:'teaching', count:2}, + {word:'not', count:2}, + {word:'else', count:2}, + {word:'do', count:2}, + {word:'I', count:2}, + {word:'which', count:1} + ] + ``` ### Exercises: Level 3 1. Write a function which cleans text. Clean the following text. After cleaning, count three most frequent words in the string. -```js -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!?` + ```js + 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!?` -console.log(cleanText(sentence)) -``` + console.log(cleanText(sentence)) + ``` -```sh -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 -``` + ```sh + 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 + ``` 1. Write a function which find the most frequent words. After cleaning, count three most frequent words in the string. -```js -console.log(mostFrequentWords(cleanedText)) -``` + ```js + console.log(mostFrequentWords(cleanedText)) + ``` -```sh -[{word:'I', count:3}, {word:'teaching', count:2}, {word:'teacher', count:2}] -``` + ```sh + [{word:'I', count:3}, {word:'teaching', count:2}, {word:'teacher', count:2}] + ``` πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 11](../11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md) | [Day 13>>](../13_Day_Console_object_methods/13_day_console_object_methods.md) \ No newline at end of file +[<< Day 11](../11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md) | [Day 13>>](../13_Day_Console_object_methods/13_day_console_object_methods.md)