Skip to content

Latest commit

 

History

History
executable file
·
1 lines (1 loc) · 581 Bytes

File metadata and controls

executable file
·
1 lines (1 loc) · 581 Bytes

Let's take a look at these methods one by one. The replace() method replaces the first occurrence of 'A' with 'Z'. This is why the new string starts with 'Z' instead of 'A'. The search() method searches for the first occurrence of 'A' using regular expression and prints the index, which is why 0 is printed to the console. The indexOf() method returns the index of the first occurrence of 'B' starting from the left, which is why 1 is printed to the console. The lastIndexOf method return the index of the last occurrence of 'B', which is why 21 is printed to the console.