-6

How will this outputs to be 64 and 20?

I have got a question from one of my assessments and need to know the answer to that.

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<p id='test'></p>
<p id='test1'></p>
<script>
    document.getElementById('test').innerHTML = -"4"+10+"4";
    document.getElementById('test1').innerHTML = "5"*3+5;
</script>
</body>
</html>
Makyen
  • 31,849
  • 12
  • 86
  • 121

1 Answers1

1

With -"4"+10+"4"; => -"4"+10 is 6 and it is concatenated with 4 hence 64

With "5"*3+5; => "5"*3 is 15 and 5 is added to it hence 20

Important things to consider here are:

Rayon
  • 36,219
  • 4
  • 49
  • 76