Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Replace Part of a String with another String</title> </head> <body> <script> let str = "Color red looks brighter than color blue."; let result = str.replace("color", "paint"); document.write(result); // 0utputs: Color red looks brighter than paint blue. </script> </body> </html>