+ 5

I can't understand this?

What will be the content of the paragraph after the user clicks on it twice? <p id='txt' onclick='test();'>20</p> <script> function test() { var x=document.getElementById('txt'); var n = x.innerHTML; x.innerHTML = n/2; } </script> How the answer is 5?

15th Oct 2017, 5:06 AM
dharmesh B
dharmesh B - avatar
5 Respuestas
+ 18
"How the answer is 5?" Because as you click on the paragraph twice, it makes it (20/2 = 10) on the first click and (10/2 = 5) on the second click.
15th Oct 2017, 5:10 AM
Dev
Dev - avatar
+ 6
Because it have been clicked twice. On first click: 20/2 = 10 On second click: 10/2 = 5 That's how the answer is 5.
15th Oct 2017, 7:29 AM
Biraj Patel
+ 2
5
23rd May 2020, 7:10 PM
Pramod Vishwakarma
Pramod Vishwakarma - avatar
0
i seee
26th Oct 2017, 8:00 AM
Agustinus Giri Hartono
Agustinus Giri Hartono - avatar
0
i think the answer is == 5
5th Oct 2022, 9:14 AM
Manshaf Jamsith
Manshaf Jamsith - avatar