Northcentral Technical College Introduction To Programming
10-152-310
Introduction to Programming with JavaScript NTC 10-152-310

Learning Plan 6 6.2 Lab 1

# 6.2 Lab 1

#### File: /Learning Plan 6/6.2lab1.html

### Student

- Name:
- Section:
- Email:

### Lab Specifications

- Open this file in Firefox and Microsoft Visual Studio.
- Add your name, section, and email.
- Open the file `/Learning Plan 6/jsFiles/6.2lab1.js` in Microsoft Visual Studio.

#### Lab Steps

1. In the JavaScript file, `/Learning Plan 6/jsFiles/6.2lab1.js`, create a program that will collect strings into an array.
2. On the HTML page, create a form with one input text field and a submit button.
3. Give the form an id attribute.
4. In the output `<div>` tag, add an HTML element that allows you to add elements. Maybe a `<ul>` or a `<ol>` tag.
5. Have the `onsubmit` attribute call the `lab62_1()` function.
6. Now switch to the JavaScript file file, `6.2lab1.js`.
7. Create a `global` array variable that will hold strings. It has to be global so that it will keep the array elements that you add. If it was local to a function, it would be wiped out every time we ran the function. Initialize it when you declare it like this:
   - `var enteredStrings = [];`
8. In the `lab62_1()` function, create a local variable that will hold the display element.
9. Get the display element and assign it to the previous variable.
10. When the form is submitted, get the value in the text field and add it to the end of the array.
11. Create a loop that goes through the array and outputs each array element to the display HTML element.
12. Test your code by adding several strings. They should appear in the display element.

### Your Form and Output:

## 6.2 Assignemnt 1

- 6.2 Assignment 1