Multiple choice

Predict the output of the following JavaScript code : a = 8 + "8"; document.write(a);

  1. 16

  2. Complilation Error

  3. 88

  4. Run Time Error

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In JavaScript, when the '+' operator is used with a number and a string, the number is implicitly coerced into a string. The two strings are then concatenated, so 8 + '8' results in the string '88'.