Tricky javascript question 🤪 let’s go #computerscience #softwareengineer #coding #javascript

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

It gives an error obviously the 1 + + '2' part is wrong
If we fix that then its going to output 122 which is C
The reason is javascript type conversion happens in a way that if the two values dont match it will just convert it to a string

Edit: I ran the code and voila it gave 122. Please if you do tutorials and such make sure its at least correct.

Trabaldurr
Автор

Output is 32.

Because if we add number and string, it will return output as string. In this case, we use type casting to solve the problem. If we use + operator before a string which holds a number, it will be converted from string to number.

Solution:

1+ +'2' This returns 3. Because Type casted.
After 3 concat with a string '2', it returns 32

So the solution is 32

dp_editz_
Автор

okay i didnt even know this and just assumed it would be 32 didn’t have an explanation thats just a pure luck guess

crypticpeel
Автор

Obviously 32. what's the problem?

しめい-lm
Автор

anyone know how to get into a javascript course??

Jibs-iqem
Автор

Beginners going mad pls click a like here!!!!😅😅😅

RinRaja
visit shbcf.ru