Introduction To Programming
10-152-310

Learning Plan 2 : Variables and Data Types

Source Code

    
        

Demo Output


        

Explanation

     tags after it
        document.write("The mystery variable is ");
        document.write(whatWillThisBe);
        document.write("

"); // Display the mystery variable with a concatenation, // we'll learn about this in the next learning unit. document.write("Here's it is again " + whatWillThisBe + "
"); ]]>
  • Line 5 declares the variable "tabInThisVariable" which has an embedded tab character ("\t").
  • Line 6 declares the variable "aNewLineInTheMiddle" which has an embedded newline character in its middle.
  • Line 9 declares the mystery variable.
  • Line 12 prints the "tabInThisVariable" variable to the page. The tab character has a gap bigger than a space.
  • Line 14 prints two newline characters to the page.
  • Line 17 prints the "aNewLineInTheMiddle" variable to the page. The embedded newline character splits the display to two lines.
  • Line 19 prints two newline characters to the page.
  • Lines 23-25 prints the mystery variable to the page with text in front of it and after it.
  • Lines 29 also prints the mystery variable to the page with text in front of it and after it. This time concatenation is used.