|
|
@ -645,12 +645,16 @@ string.match(substring)
|
|
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
```js
|
|
|
|
let string = 'I love JavaScript. If you do not love JavaScript what else can you love.'
|
|
|
|
let string = 'I love JavaScript. If you do not love JavaScript what else can you love.'
|
|
|
|
console.log(string.match('love')) //
|
|
|
|
console.log(string.match('love'))
|
|
|
|
/*
|
|
|
|
```
|
|
|
|
output
|
|
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
|
|
|
//output
|
|
|
|
|
|
|
|
|
|
|
|
["love", index: 2, input: "I love JavaScript. If you do not love JavaScript what else can you love.", groups: undefined]
|
|
|
|
["love", index: 2, input: "I love JavaScript. If you do not love JavaScript what else can you love.", groups: undefined]
|
|
|
|
*/
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
let pattern = /love/gi
|
|
|
|
let pattern = /love/gi
|
|
|
|
console.log(string.match(pattern)) // ["love", "love", "love"]
|
|
|
|
console.log(string.match(pattern)) // ["love", "love", "love"]
|
|
|
|
```
|
|
|
|
```
|
|
|
@ -658,10 +662,13 @@ console.log(string.match(pattern)) // ["love", "love", "love"]
|
|
|
|
Let us extract numbers from text using regular expression. This is not regular expression section, no panic.
|
|
|
|
Let us extract numbers from text using regular expression. This is not regular expression section, no panic.
|
|
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
```js
|
|
|
|
let txt = 'In 2019, I run 30 Days of Pyhton. Now, in 2020 I super exited to start this challenge'
|
|
|
|
let txt = 'In 2019, I run 30 Days of Python. Now, in 2020 I super exited to start this challenge'
|
|
|
|
let regEx = /\d+/ // d with escape character means d not a normal d instead acts a digit
|
|
|
|
let regEx = /\d+/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// d with escape character means d not a normal d instead acts a digit
|
|
|
|
// + means one or more digit numbers,
|
|
|
|
// + means one or more digit numbers,
|
|
|
|
// if there is g after that it means global, search everywhere.
|
|
|
|
// if there is g after that it means global, search everywhere.
|
|
|
|
|
|
|
|
|
|
|
|
console.log(txt.match(regEx)) // ["2", "0", "1", "9", "3", "0", "2", "0", "2", "0"]
|
|
|
|
console.log(txt.match(regEx)) // ["2", "0", "1", "9", "3", "0", "2", "0", "2", "0"]
|
|
|
|
console.log(txt.match(/\d+/g)) // ["2019", "30", "2020"]
|
|
|
|
console.log(txt.match(/\d+/g)) // ["2019", "30", "2020"]
|
|
|
|
```
|
|
|
|
```
|
|
|
@ -693,14 +700,16 @@ let lastName = 'Yetayeh' // string
|
|
|
|
let country = 'Finland' // string
|
|
|
|
let country = 'Finland' // string
|
|
|
|
let city = 'Helsinki' // string
|
|
|
|
let city = 'Helsinki' // string
|
|
|
|
let age = 250 // int, it is not my real age, do not worry about it
|
|
|
|
let age = 250 // int, it is not my real age, do not worry about it
|
|
|
|
|
|
|
|
let job
|
|
|
|
|
|
|
|
|
|
|
|
console.log(typeof 'Asabeneh') // str
|
|
|
|
console.log(typeof 'Asabeneh') // string
|
|
|
|
console.log(typeof firstName) // str
|
|
|
|
console.log(typeof firstName) // string
|
|
|
|
console.log(typeof 10) // number
|
|
|
|
console.log(typeof 10) // number
|
|
|
|
console.log(typeof 3.14) // number
|
|
|
|
console.log(typeof 3.14) // number
|
|
|
|
console.log(typeof true) // boolean
|
|
|
|
console.log(typeof true) // boolean
|
|
|
|
console.log(typeof false) // boolean
|
|
|
|
console.log(typeof false) // boolean
|
|
|
|
console.log(typeof NaN) // number
|
|
|
|
console.log(typeof NaN) // number
|
|
|
|
|
|
|
|
console.log(typeof job) // undefined
|
|
|
|
console.log(typeof undefined) // undefined
|
|
|
|
console.log(typeof undefined) // undefined
|
|
|
|
console.log(typeof null) // object
|
|
|
|
console.log(typeof null) // object
|
|
|
|
```
|
|
|
|
```
|
|
|
@ -845,7 +854,7 @@ The quote 'There is no exercise better for the heart than reaching down and lift
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
40. Check if typeof '10' is exactly equal to 10. If not make it exactly equal.
|
|
|
|
40. Check if typeof '10' is exactly equal to 10. If not make it exactly equal.
|
|
|
|
20. Check if parseInt('9.8') is equal to 10 if not make it exactly equal with 10.
|
|
|
|
41. Check if parseInt('9.8') is equal to 10 if not make it exactly equal with 10.
|
|
|
|
|
|
|
|
|
|
|
|
🎉 CONGRATULATIONS ! 🎉
|
|
|
|
🎉 CONGRATULATIONS ! 🎉
|
|
|
|
|
|
|
|
|
|
|
|