Evaluating “1”+2+3+4+5=? in JavaScript.

Vishalneeraj-24503
Posted by Vishalneeraj-24503 under JavaScript category on | Points: 40 | Views : 209
<script language = "javascript" type = "text/javascript">
function Evaluate()
{
var i = "1";
var j = 2;
var k = 3;
var l = 4;
var m = 5;
alert(i + j + k + l + m);
}
</script>
<input type = "button" id= "btn_calc" value ="Click"
onclick = "Javascript:Evaluate();" />

Output:-
12345

Because “i” is string so all the variables considered as a string.

Comments or Responses

Login to post response