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