Consider following code:

var a  = 44;
        (function(){
            var b = 44;
            a = '55';
            (function(){
                var c = 11;
                alert((a+b)/c);
            })();
        })();    
What will be the result of the code?
Explanation
When you trying to add a string and a number the + operator acts as a concatenation operator:

var a =44;
var b = '55'
a+ b // '4455' - string
Division (/) operator converts a string to a number:

var c = 11;
return ((a+b)/c); // 504

@nbkeeprocki54 thanks, updated!

2018 Sep 23, 7:33:05 AM

a + b = "5544", not "4455" in explanation

2018 Jul 2, 9:01:29 AM

Russian text

2018 Jun 21, 1:15:44 PM

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes