When you print showingValue
, the browser executes the script and displays 4. When you compare the strings, it doesn't execute the script, so it literally compares the strings:
"4"
is not equal to "<script>document.writeln(selectedCopyValue)</script>"