\n\n(i) error\n(ii) BEU_Javascript\n(iii) undefined\n(iv) BEU_Javascript","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"## Answer\n**(ii) `BEU_Javascript`**\n\n### Step-by-step\n1. `txt1` is assigned the string `BEU_`.\n2. `txt2` is assigned the string `Javascript`.\n3. The `+` operator concatenates the two strings.\n4. Therefore, `txt1 + txt2` becomes `BEU_Javascript`.\n5. `innerHTML` places that result inside the element with `id=\"demo\"`.\n\n```javascript\nvar txt1 = \"BEU_\";\nvar txt2 = \"Javascript\";\ndocument.getElementById(\"demo\").innerHTML = txt1 + txt2;\n```\n\n**Final answer: (ii) `BEU_Javascript`**\n\n> Note: Options (ii) and (iv) appear duplicated in the supplied paper; the value is still `BEU_Javascript`. "}}}Back to the 2023 paper

Module III: Basics of Web Programming

20232m

What will be the output of the following JavaScript code snippet?

<p id="demo"></p> <script> var txt1 = "BEU_"; var txt2 = "Javascript"; document.getElementById("demo").innerHTML = txt1 + txt2; </script>

(i) error
(ii) BEU_Javascript
(iii) undefined
(iv) BEU_Javascript

Worked SolutionAI Assisted

Answer

(ii) BEU_Javascript

Step-by-step

  1. txt1 is assigned the string BEU_.
  2. txt2 is assigned the string Javascript.
  3. The + operator concatenates the two strings.
  4. Therefore, txt1 + txt2 becomes BEU_Javascript.
  5. innerHTML places that result inside the element with id="demo".
var txt1 = "BEU_";
var txt2 = "Javascript";
document.getElementById("demo").innerHTML = txt1 + txt2;

Final answer: (ii) BEU_Javascript

Note: Options (ii) and (iv) appear duplicated in the supplied paper; the value is still BEU_Javascript.

Similar questions