Thành Nguyễn
New member
What will be the output of the following JavaScript code?
A. one
B. two
C. error
D. undefined
Code:
<button onclick="myFunction()">Try it</button>
<p id="demo">one</p>
<script>
function myFunction()
{
var str = document.getElementById("demo").innerHTML;
var txt = str.replace("one","two");
document.getElementById("demo").innerHTML = txt;
}
</script>
B. two
C. error
D. undefined