You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
553 B
12 lines
553 B
// indexOf(): Takes takes a substring and if the substring exists in a string it returns the first position of the substring if does not exist it returns -1
|
|
|
|
string.indexOf(substring)
|
|
let string = '30 Days Of JavaScript'
|
|
console.log(string.indexOf('D')) // 3
|
|
console.log(string.indexOf('Days')) // 3
|
|
console.log(string.indexOf('days')) // -1
|
|
console.log(string.indexOf('a')) // 4
|
|
console.log(string.indexOf('JavaScript')) // 11
|
|
console.log(string.indexOf('Script')) //15
|
|
console.log(string.indexOf('script')) // -1
|