Cañalita Wad 1 M4

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Cañalita, Dan Carlo C.

BSIT-2 WAD 101

Self-Assessment 1 (10pts).

What is the potential problem with globally scoped variables?

The problem with global variables is that since every function has access to these, it becomes
increasingly hard to figure out which functions actually read and write these variables. To understand
how the application works, you pretty much have to take into account every function which modifies the
global state.

Self-Assessment 2 (10pts).

What does this do?

Document.getElementById(“main”)

- Returns an Element object representing the element whose id property matches the specified
string.

Self-Assessment 3 (10pts).

What does this do?

Document.body.style.backgroundColor = “papayawhip”

- It sets the background color of the page (body element) to “papayawhip”.

Activity 1 (10pts)

Given the following array

Var myArray = [1, “two”, 3, “4”]

Write what the alert message will say for each of these examples:

a. Alert( myArray[0] );

// Alert “1”

b. Alert( myArray[0] + myArray[1] );

// Alert “1two”

c. Alert( myArray[2] + myArray[3] );


// Alert “34”

d. Alert( myArray[2] – myArray[0] );

// Alert “2”

Activity 2 (10pts)

What will each of these alert messages say?

a. Var foo = 5;

Foo += 5;

Alert( foo );

// This will alert “10”

b. Var foo = 2;

Alert( foo + “ “ + “remaining”);

// This will alert “ 2 remaining “

c. Var foo = “Mat”;

Var bar = “Jennifer”;

If( foo.length > bar.length ) {

Alert( foo + “ is longer.” );

} else {

Alert( bar + “ is longer.” );

// This will alert “ Jennifer is longer ”

d. Alert( 10 === “10” );


/* This will alert“ false “ They’re both “10”, but they’re not the same data types. */

You might also like