What will be output? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

What will be output?

alert('Sign Up'); document.write("Hello") ; var x = "5" ; document.write(x++); Pls tell me output of this I want output to be first display alert sign up the show Hello and then no. 6 will be printed. If there was mistake pls tell me https://webknowledgepedia.wordpress.com/

3rd Oct 2020, 4:36 AM
Knowledge Pedia
Knowledge Pedia - avatar
5 Respuestas
+ 2
Ananaya Jemberu So what should i change?
3rd Oct 2020, 4:50 AM
Knowledge Pedia
Knowledge Pedia - avatar
+ 2
Thnx it worked
3rd Oct 2020, 5:10 AM
Knowledge Pedia
Knowledge Pedia - avatar
+ 2
In javascript (var x = "5"; document.write(x++)) will not throw an error, "5" will be converted to the number 5, this is due to type conversion. https://javascript.info/type-conversions You should use prefix increment operator(++x) to get the results you are expecting, not postfix increment operator(x++). https://javascript.info/operators#increment-decrement https://code.sololearn.com/W1HGsJ52j3Di/#html
3rd Oct 2020, 10:55 AM
ODLNT
ODLNT - avatar
+ 1
Thnx ODLNT
3rd Oct 2020, 11:56 AM
Knowledge Pedia
Knowledge Pedia - avatar
+ 1
Knowledge Pedia You are welcome. I'm glad I could help.
4th Oct 2020, 1:48 AM
ODLNT
ODLNT - avatar