Introduction To Programming
10-152-310

Learning Plan 2 : Variables and Data Types

Student

  • Name:
  • Section:
  • Email:

Lab Steps

  • Open this file in your browser and Microsoft Visual Studio
  • Add your name, section, and email
  • In the coding section below, add these variables:
    • a variable that holds a name, put your name in the variable
    • a variable that holds an address, put a fake address in the variable
    • a variable that holds a count, put the number 10 in the variable
    • a variable that holds a price, put an amount of "12.99" in the variable
  • Now display the variables using the document.write(); function
    • Use a separate statement for each variable
  • Does your code follow the course coding standards? (JavaScript Coding Standards for 10-152-310)
  • Run your program. Did you see something like this?
Eric123 Some St.1012.99
  • It's all on one line...
  • document.write(); does not make its output go on the next line. You have to do that yourself. Here's how to do it:
    • document.write("<br />"); (add a line break tag to the output)
    • document.write("\n"); (add a line break escape character to the output)
    • document.writeln("..."); (use writeln to add a carriage return)
    • You will need to have one of these when you want the next piece of data to be on the next line.
    Eric
    123 Some St.
    10
    12.99
        

That's better!

Your Output

			
        

What You Did

You practiced creating some JavaScript variables and then displaying their values on the lab page. You learned that we need to add a line break in our output to have new lines of text.