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/i, "paint"); document.write(result); // 0utputs: paint red looks brighter than color blue. </script> </body> </html>