From 6f16325085f3baa4a2945cf5271e801e849a6722 Mon Sep 17 00:00:00 2001 From: Patrick Njuguna Date: Sat, 18 Jan 2020 13:28:21 +0300 Subject: [PATCH 1/3] regular expressions examples typo fixes --- 12_Day/12_day_regular_expressions.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/12_Day/12_day_regular_expressions.md b/12_Day/12_day_regular_expressions.md index 71f95f73..676085a5 100644 --- a/12_Day/12_day_regular_expressions.md +++ b/12_Day/12_day_regular_expressions.md @@ -350,7 +350,7 @@ Zero or many times. The pattern could may not occur or it can occur many times. const pattern = /[a].*/g //. any character, + any character one or more times const txt = 'Apple and banana are fruits' -const matches = re.match(pattern) +const matches = txt.match(pattern) console.log(matches) // ['and banana are fruits'] @@ -383,7 +383,7 @@ console.log(matches) // ['2019'] ```js const txt = 'This regular expression example was made in December 6, 2019.' -const regex_pattern = /\d{1, 4}/g // 1 to 4 +const pattern = /\d{1,4}/g // 1 to 4 const matches = txt.match(pattern) console.log(matches) // ['6', '2019'] ``` @@ -396,7 +396,7 @@ console.log(matches) // ['6', '2019'] const txt = 'This regular expression example was made in December 6, 2019.' const pattern = /^This/ // ^ means starts with const matches = txt.match(pattern) -console.log(matches) / ['This'] +console.log(matches) // ['This'] ``` - Negation @@ -405,12 +405,12 @@ console.log(matches) / ['This'] const txt = 'This regular expression example was made in December 6, 2019.' const pattern = /[^A-Za-z,. ]+/g // ^ in set character means negation, not A to Z, not a to z, no space, no coma no period const matches = txt.match(pattern) -console.log(matches) ["6", "2019"] +console.log(matches) // ["6", "2019"] ``` ### Exact match -It should hav ^ starting and $ which is an end. +It should have ^ starting and $ which is an end. ```js let pattern = /^[A-Z][a-z]{3,12}$/; From e9b7ce001be7c36b7add6179bdea796f9ccc81b8 Mon Sep 17 00:00:00 2001 From: Patrick Njuguna Date: Sat, 18 Jan 2020 14:01:04 +0300 Subject: [PATCH 2/3] default values with constructor fix to allow example to be run without returning already defined error --- 15_Day/15_day_classes.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/15_Day/15_day_classes.md b/15_Day/15_day_classes.md index e878e537..400d03d0 100644 --- a/15_Day/15_day_classes.md +++ b/15_Day/15_day_classes.md @@ -204,9 +204,10 @@ class Person { } const person1 = new Person() // it will take the default values -const person1 = new Person('Lidiya', 'Tekle', 28, 'Finland', 'Espoo') +const person2 = new Person('Lidiya', 'Tekle', 28, 'Finland', 'Espoo') console.log(person1) +console.log(person2) ``` ```sh From 75a187864d0f8d81b2c22f9c46a570a538f283d8 Mon Sep 17 00:00:00 2001 From: Patrick Njuguna Date: Sat, 18 Jan 2020 14:12:00 +0300 Subject: [PATCH 3/3] json examples fix avoid using 'text' as a variable name since it is reserved and returns an error --- 16_Day/16_day_json.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/16_Day/16_day_json.md b/16_Day/16_day_json.md index b4660016..ff04882d 100644 --- a/16_Day/16_day_json.md +++ b/16_Day/16_day_json.md @@ -327,8 +327,8 @@ const users = { } } -const text = JSON.stringify(users, undefined, 4) -console.log(text) // text means JSON- because json is a string form of an object. +const txt = JSON.stringify(users, undefined, 4) +console.log(txt) // text means JSON- because json is a string form of an object. ``` ```sh @@ -446,8 +446,8 @@ const user = { points: 30 } -const text = JSON.stringify(user,['firstName', 'lastName', 'country', 'city', 'age'],4) -console.log(text) +const txt = JSON.stringify(user,['firstName', 'lastName', 'country', 'city', 'age'],4) +console.log(txt) ``` ```sh @@ -594,4 +594,4 @@ const text = `{ 🎉 CONGRATULATIONS ! 🎉 -[<< Day 15](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/15_Day/15_day_classes.md) | [Day 17 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/17_Day/17_day_web_storage.md) \ No newline at end of file +[<< Day 15](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/15_Day/15_day_classes.md) | [Day 17 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/17_Day/17_day_web_storage.md)