Added clues on index and length & fixed strings having default keywords.

pull/486/head
Zack Dx 3 years ago
parent 4e5ccf57e1
commit 24afc706fc

@ -7,6 +7,8 @@ let secondLetter = string[1] // a
let thirdLetter = string[2]
let lastLetter = string[9]
console.log(lastLetter) // t
let lastIndex = string.length - 1
let lastIndex = string.length -1
console.log(lastIndex) // 9
console.log(string[lastIndex]) // t
//Remember always in JS Index starts with 0 & Length you can count from 1.

@ -1,17 +1,17 @@
// match: it takes a substring or regular expression pattern as an argument and it returns an array if there is match if not it returns null. Let us see how a regular expression pattern looks like. It starts with / sign and ends with / sign.
let string = 'love'
let str = 'love'
let patternOne = /love/ // with out any flag
let patternTwo = /love/gi // g-means to search in the whole text, i - case insensitive
string.match(substring)
let string = 'I love JavaScript. If you do not love JavaScript what else can you love.'
console.log(string.match('love')) //
console.log (str.match('love'))
let str2 = 'I love JavaScript. If you do not love JavaScript what else can you love.'
console.log(str2.match('love')) //
/*
output
["love", index: 2, input: "I love JavaScript. If you do not love JavaScript what else can you love.", groups: undefined]
*/
let pattern = /love/gi
console.log(string.match(pattern)) // ["love", "love", "love"]
console.log(str.match(pattern)) // ["love", "love", "love"]
// Let us extract numbers from text using regular expression. This is not regular expression section, no panic.
let txt = 'In 2019, I run 30 Days of Python. Now, in 2020 I super exited to start this challenge'

Loading…
Cancel
Save