4.
Which method is used to replace specific characters in a string with new characters?
replace()
join()
reverse()
substr()
Correct: A
The replace() method is used to replace specific characters or substrings in a string with new characters or substrings. It takes two parameters: the first parameter is the character(s) or substring to be replaced, and the second parameter is the new character(s) or substring to replace it with. The join() method is used to join all elements of an array into a string, the reverse() method is used to reverse the order of characters in a string, and the substr() method is used to extract a specified number of characters from a string, starting at a specified position.