var str1 = "Pedro";
var str2 = "Bye " + str1;
function changeStr() {
str1 = "Dom";
}
console.log("Before", str2);
changeStr();
console.log("After", str2);
I want the above code to print "Bye Dom" instead of "Bye Pedro". Also please attach the link from where I can get the conceptual knowledge for this.
str2is never changed? What makes you think it would be different?var str2 = "Bye " + str1;stores the string "Bye Pedro" instr2. Changingstr1afterwards doesn't changestr2.replacemethod - the conceptual knowledge for how you are doing it can be found in any javascript introduction