Section 1

Preview this deck

-1

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

1 year ago

Date created

Mar 1, 2020

Cards (381)

Section 1

(50 cards)

-1

Front

what does this return for the value of bar? var foo = "monkey, gibby, willow, clancy, boone"; var bar = foo.indexOf("44"); console.log(bar);

Back

prompt example: var userInput = prompt("what is your favorite color"); console.log(userInput); its ok to say window.prompt

Front

whats the keyword to get info from user?

Back

3

Front

var text = "To be or not to be."; var indx = text.indexOf("be"); What is the value of indx?

Back

variable

Front

In one word, what is a flag?

Back

lastIndexOf

Front

What is the keyword for finding the index of the first character of the last instance of a segment?

Back

else

Front

What keyword specifies an action when all tests above have failed?

Back

pets = pets.slice(3, 5);

Front

var pets = ["dog", "cat", "ox", "duck", "frog"]; Reduce it to "duck" and "frog" using slice.

Back

pets = pets.slice(3, 5);

Front

var pets = ["dog", "cat", "ox", "duck", "frog", "flea"]; Reduce it to "duck" and "frog" using slice.

Back

LC

Front

Two characters in this code are incorrect. Type the two correct characters. var allLower = userInput.tolowercase();

Back

4, string.length;

Front

You want to take a slice out of the string that starts at the fifth character and goes to the end. Fill in the blank. var segment = someWord.slice(___);

Back

Variables can be used before they are declared x=3 console.log(x); //logs 3 var x; //declares x initialization however doesn't get hoisted. The code below yields undefined for y. <!DOCTYPE html> <html> <body> <p id="demo"></p> <script> var x = 5; // Initialize x var y; // Declare y elem = document.getElementById("demo"); // Find an element elem.innerHTML = x + " " + y; // Display x and y y = 7; // Assign 7 to y </script> </body> </html>

Front

What is hoisting in javascript?

Back

pop ex: dogs.pop();

Front

What keyword removes the last element from an array?

Back

2

Front

how many times will the if statement execute? for (var i = 0; i < 10; i++) { if (i === 1) { alert(i); break; } }

Back

yes

Front

If you have an empty array defined in line 1 like so: var foo = []; is it legal to say this? foo[3] = "hello";

Back

pets = pets.splice(1, 2);

Front

var pets = ["dog", "cat", "ox", "duck", "frog"]; Remove "cat" and "ox".

Back

if (condition) { block of code to be executed if the condition is true }

Front

what is the syntax for if statement

Back

dogs = dogs.splice(2, 1, "dachshund");

Front

How would you add "dachshund" to the 3rd element of the following array while removing "Bob"? var dogs = ["Hound", "Lab", "Bob", "Great Dane"];

Back

there are 2 options: 1) put inside script tags like so: <script> Var add = function(x,y) { Var z = x+y; Return z } Var sum = add(2,3); Alert (sum); </script> 2) add a reference to a .js file like so <script type="text/javascript" src="Scripts/tests.js" async></script>

Front

Whats the syntax for adding javascript to your html page?

Back

comparison

Front

===, !==, >, and <= are ________ operators.

Back

splice

Front

What keyword inserts new elements anywhere in an array and/or removes elements from an array?

Back

Assign value of x to what is in y

Front

what does x = y mean

Back

pets.splice(1, 2, "bird", "bear");

Front

This statement created the array: var pets = ["dog", "cat", "ox", "duck", "frog"]; Add 2 elements after "dog" and remove "cat", "ox", and "duck".

Back

charAt

Front

What is the keyword for finding a character at a particular location in a string?

Back

camel case myMethodName

Front

what is the naming convention for javascript methods

Back

x is equal to and equal type of y

Front

what does x === y mean?

Back

1, 3

Front

"captain" has been assigned to someWord. You want to slice "ap" out of it. Fill in the blank. var segment = someWord.slice(___);

Back

for (var i = 0; i < 4; i++) {

Front

Code the first line of a for loop with the usual counter name, usual starting value, and usual increment. Run it 4 times using < to specify how many loops

Back

break

Front

What is the keyword that stops a loop from continuing to loop?

Back

onchange - An HTML element has been changed onclick - The user clicks an HTML element onmouseover - The user moves the mouse over an HTML element <span onmouseover="this.style.color='red'">Mouse over me!</span> onmouseout - The user moves the mouse away from an HTML element onkeydown - The user pushes a keyboard key onload - The browser has finished loading the page

Front

Name 5 HTML events - and basic example of how javascript can handle those events

Back

()

Front

Type the characters that are missing from this code. var allLower = userInput.toLowerCase;

Back

indexOf

Front

What is the keyword for finding the index of the first character of a segment?

Back

no!

Front

What is the value of lowerVersion? Include the quotation marks in your answer. var lowerVersion = "NO!".toLowerCase();

Back

%

Front

Whats the character for modulus (remainder of dividing 2 numbers)

Back

shift unshift

Front

What keyword removes the first element of an array what keyword adds to the first element of an array

Back

for (var j = 0; j < 100; j++) {

Front

Code the first line of a for loop with a counter name that's not i. Code the usual starting value and usual increment. Run it 100 times using < to specify how many loops.

Back

slice

Front

What is a method for extracting a segment from a string?

Back

remember slice creates a copy - doesnt change the arrray slice(arg1, arg2); arg1 = where to start index arg2 = where to finish index + 1

Front

what are the arguments to pass in the slice function

Back

case sensitive officially named ECMA Script its the language of the browser - much like VBA and macros were/are the language of MS Word, etc Acts on the DOM (browser's representation of page)

Front

Name at least 3 characteristics of javascript

Back

var segIndex = text.lastIndexOf("x");

Front

Find the index of the first character of the last instance of a literal string segment in a string represented by a variable, and assign it to another variable, which hasn't been declared beforehand.

Back

slice slice(index of element to begin copy, index of element to end copy + 1)

Front

what keyword can be used to copy elements of an array to another

Back

splice(arg1, arg2, arg3); arg1 = where to start index arg2 = how many to delete arg3 = what to add (can be array)

Front

what are the arguments you pass in the splice function?

Back

for (var i = 0; i > -3; i--) {

Front

Code the first line of a for loop with the usual counter and the usual starting value. Run it 3 times using > to specify how many loops. Decrement it with each iteration.

Back

length

Front

The statement assigns the number of elements in the array to the variable. Fill in the blank. var num = myStr.________;

Back

pets = pets.splice(1, 3, "bear", "horse");

Front

var pets = ["dog", "cat", "ox", "duck", "frog"]; Add 2 elements after "dog" and remove "cat", "ox", and "duck".

Back

var airlines = [];

Front

how would you create an empty array?

Back

var segIndex = text.indexOf("x");

Front

Find the index of the first character of the first instance of a literal string segment in a string represented by a variable, and assign it to another variable, which hasn't been declared beforehand.

Back

if (indexNum !=== -1) {

Front

Code the first line of an if statement that tests whether a segment with an index represented by indexNum exists in a string.

Back

else if

Front

What are the keywords that test for a condition when all tests above it have failed?

Back

slice

Front

What keyword copies elements from an array to another array?

Back

foo.push(2, 3, 5);

Front

How would you add 3 numbers to the end of an array?

Back

Section 2

(50 cards)

a 16 digit decimal between 0 and 1, but not including 1

Front

What gets assigned to var randomNumber = Math.random();

Back

getTime You start with milliseconds, then convert it to days, hours, or whatever you need.

Front

What is the keyword for extracting the basic time unit you need for figuring intervals?

Back

str.length -1

Front

The last character of the string is assigned to the variable. Fill in the blank, using the string length to specify the index. var lastChar = str.charAt(________);

Back

str.length - 1

Front

The last character of the string is assigned to the variable. Fill in the blank, using the string length to specify the index. var lastChar = str.charAt(________);

Back

var foo = getTime() / (1000 60 60);

Front

Code a statement that converts the milliseconds represented by ticks to hours and assigns the result to a variable that hasn't been declared beforehand.

Back

hello();

Front

Write a function call. Name it anything you like,

Back

:00:00

Front

You're creating a Date object for noon on the dot. Fill in the blank. var prev = new Date("January 1, 2000 _______");

Back

var newStr = str.replace("1", "one");

Front

In a string represented by str replace the first instance of "1" with "one" and assign the revised string to newStr, which hasn't been declared beforehand.

Back

function calc(a, b) {

Front

The function call is: calc("Funds received", 500000); Code the first line of the function.

Back

var foo = new Date("January 1, 2016");

Front

Create a Date object for the first day of 2016

Back

function

Front

In one word, what is a block of code that executes whenever you invoke its name?

Back

parameters

Front

The variables in a function definition that catch the data passed to them by the calling code are called _________.

Back

if (d.getMinutes() === 0 && d.getSeconds() === 0) {

Front

Code the first line of an if statement that tests whether the clock is at an hour on the dot. Check minutes and then seconds. Ignore milliseconds. Use any variable you like to represent the Date object.

Back

foo = foo.replace(/my house/g, "our house");

Front

var foo = "my house in the middle of the street"; write a statement that changes all occurrences of "my house" to "our house"

Back

var numStr = num.toString();

Front

Convert the number represented by num to a string and assign the string to numStr, which hasn't been declared beforehand.

Back

foo = foo.toFixed();

Front

Code a statement that rounds a number represented by a variable to no places, converts it to a string, and assigns it to the same variable.

Back

function foo() { foo(); }

Front

Write a function that calls itself

Back

var newStr = str.replace(/1/g, "one");

Front

In a string represented by str replace all instances of "1" with "one" and assign the revised string to newStr, which hasn't been declared beforehand.

Back

alert(d.getFullYear());

Front

The Date object is represented by d. Code a statement that displays the year in an alert.

Back

getMilliseconds

Front

What is the keyword for extracting the smallest unit of time that JavaScript recognizes?

Back

"zbc abc"

Front

After these two statements execute, what is the value of x? Include quotation marks. var x = "abc abc"; x = x.replace("a", "z");

Back

str = str.replace(/foo/g, "bar");

Front

In a string represented by a variable replace all instances of one string with another and assign the revised string to the original variable.

Back

var earlyTime = new Date("January 1, 1901 00:00:01");

Front

Create a Date object for the first second of the first day of the first month of 1901 and assign it to a variable that hasn't been declared beforehand.

Back

var foo = Math.floor(.5);

Front

Round .5 to 0 and assign it to a variable that hasn't been declared beforehand.

Back

var secsSince = d.getTime() / 1000;

Front

Code a statement that determines the seconds since midnight, Jan. 1, 1970 and assigns it to a variable that hasn't been declared beforehand. Use any variable you like to represent the Date object. Note that I'm asking for seconds. Don't round it.

Back

//g

Front

If you want all instances replaced, enter 3 characters that need to appear in this statement. var y = x.replace("a", "z");

Back

"zbc"

Front

After these two statements execute, what is the value of x? Include quotation marks. var x = "abc"; x = x.replace("a", "z");

Back

alert(new Date("January 1, 1980").getTime());

Front

Code a single statement that displays in an alert the milliseconds that elapsed between the reference date and the beginning of 1980.

Back

toString

Front

What is the keyword for converting a number to a string?

Back

parseInt("1.5");

Front

Write the code to convert "1.5" to 1?

Back

toFixed()

Front

The keyword that rounds a number to a specified number of decimal places and converts it to a string is _____.

Back

if (now.getMonth() > 8) {

Front

The Date object is represented by now. Code the first line of an if statement that tests whether it's the last quarter of the year

Back

1

Front

What is the value of roundedNum? var roundedNum = Math.floor(1.9);

Back

string

Front

What is the type of foo below: var foo = num.toFixed();

Back

foo(barr, "a string", 34);

Front

Code a function call that takes a variable, a string, and a number as arguments.

Back

Math.ceil

Front

Fill in the blank to round up. var roundedNum = ___________(fractionalNum);

Back

var intgr = n.toFixed();

Front

Code a statement that rounds a number represented by n to no places, converts it to a string, and assigns it to intgr, which hasn't been declared beforehand.

Back

()

Front

The statement will round the number to an integer. Fill in the blank. var newNum = oldNum.toFixed___;

Back

var dec3 = n.toFixed(3);

Front

Code a statement that rounds a number represented by n to 3 places, converts it to a string, and assigns it to dec3, which hasn't been declared beforehand.

Back

var theDate = new Date();

Front

write a statement that declares and creates a new date object (remember case sensitive)

Back

var x = d.getDay();

Front

Code a statement that extracts whether it's Monday, Tuesday, etc. (as a number) from the Date object represented by d and assigns it to x, which hasn't been declared beforehand.

Back

getFullYear

Front

What is the keyword for extracting the year?

Back

if (d.getHours() < 12) {

Front

Code the first line of an if statement that tests whether it's before noon. Use d to represent the Date object - which has already been created.

Back

replace

Front

What is the keyword for removing one set of characters and inserting another set in its place?

Back

var foo = new Date(); //console.log(foo.getHours()); foo.setHours(6); console.log(foo.getHours());

Front

Create a new date object, then set the hours to 6, then log the modified hours out to the console.

Back

getDate

Front

What is the keyword for extracting the day of the month?

Back

getTime();

Front

What is the code for extracting the milliseconds since midnight, Jan. 1, 1970?

Back

Number

Front

What is the keyword for converting an integer string or floating-point number string, to its equivalent number?

Back

var sum = Number(num1) + Number(num2);

Front

num1 is "1", num2 is "3". Rewrite this statement so sum is assigned 4. var sum = num1 + num2;

Back

[]

Front

Type the characters that are incorrect. var cha = sentence.charAt[10];

Back

Section 3

(50 cards)

<img src="click.png"

Front

When the image click.png is clicked, an alert displays saying, "You clicked the pic" Fill in the blank. ________________ onClick="alert('You clicked the pic');">

Back

<input type="text" onFocus="this.style.backgroundColor = 'yellow';">

Front

Display a text field. When the user clicks in the field, the field turns yellow.

Back

document

Front

Fill in the blank var nameEntered = ________.getElementById("nameField").value;

Back

inline script

Front

What 2 words would describe the coding method used below <a href = "#" onClick = "alert("hello"); var foo = 3;">Click Me</a>

Back

<img src="click.png" onClick="alert('You clicked the pic');">

Front

When the image click.png is clicked, an alert displays saying, "You clicked the pic" Code it.

Back

}

Front

Type the last line of a switch statement.

Back

<a href="JavaScript:void(0)" onClick="alert('Hi');">Click</a>

Front

Using the approach (no #) that prevents page from scrolling to top of page, code a link that triggers an alert that says "Hi" when a link that says "Click" is clicked.

Back

var est = doSomething(foo, barred(10));

Front

Code a function call - doSomething - that has two arguments. The first argument is a variable. The second argument is another function call - doThis. The second function call takes the argument 10. The value returned by the first function is assigned to est, which hasn't been declared beforehand

Back

case true :

Front

Code the second line of a switch statement that tests for a boolean

Back

1

Front

If a function has 3 parameters, how many values can be returned to the calling code? Answer with a numeral.

Back

onClick

Front

What is the keyword that tells the browser to watch for a click on a link?

Back

switch (city) { case "Akron" :

Front

Code the first two lines of a switch statement that tests the variable city. The first case tested is "Akron"

Back

<img src="but.gif"

Front

The code displays an image, but.gif, that, when clicked, calls the function myFunc. Fill in the blank. _______________ onClick="myFunc();">

Back

var userCity = document.getElementById("city").value;

Front

Assign the value in the field with an id of "city" to the variable userCity, which hasn't been declared beforehand.

Back

/* commented code here more commented code */

Front

What is the syntax for commenting in bulk?

Back

return

Front

The keyword that sends data back to the calling code is ______.

Back

form

Front

What HTML tag encloses onSubmit? Don't include the brackets in your answer.

Back

1 Fetch the HTML page (e.g. index.html) 2 Begin parsing the HTML 3 The parser encounters a <script> tag referencing an external script file. 4 The browser requests the script file. Meanwhile, the parser blocks and stops parsing the other HTML on your page. 5 After some time the script is downloaded and subsequently executed. 6 The parser continues parsing the rest of the HTML document.

Front

What are the steps a browser takes to load a script that is not async

Back

case

Front

The second keyword used in a switch statement is _______.

Back

default : bar = 2;

Front

Code 2 lines of a switch statement that specify that a variable (already declared) is assigned a number if no specific cases are true.

Back

Anywhere as long as the asynch or defer keyword is in the markup. This tells the browser to not wait until the js has loaded before rendering the page. In old days - would put it after </body> - if the code was embedded. http://stackoverflow.com/questions/436411/where-is-the-best-place-to-put-script-tags-in-html-markup

Front

Where should the script tags go in an html document?

Back

<input type="text" onFocus="this.style.backgroundColor = 'yellow';">

Front

Code a text field. When the user clicks in it, the field turns yellow.

Back

onClick="myFunc();">

Front

The code creates a button that, when clicked, calls the function myFunc. Fill in the blank. <input type="button" value="Click" ______________

Back

local

Front

A variable declared in a function is a ________ variable.

Back

onBlur

Front

What is the keyword for detecting that a field no longer has the focus?

Back

<input type="text" onBlur="this.style.backgroundColor = 'white';">

Front

Code a text field. When it loses the focus, the field turns white.

Back

switch

Front

A switch statement begins with the keyword _________.

Back

variable

Front

When a function sends data back to the calling code, the calling code needs something to catch it. That something is usually a ________.

Back

<input type="button"

Front

The code creates a button that, when clicked, calls a function. Fill in the blank. _____________ value="Submit" onClick="myFunc();">

Back

switch(foo) { case 1 : bar = true; break;

Front

Code the first 4 lines of a switch statement that tests to see if a variable is assigned one number or another. If the first test passes, a variable (already declared) is assigned a Boolean value.

Back

<form> <input type="text" value="email"> <input type="submit" value="submit"> </form>

Front

code a simple form with no event that collects an email address (no validation) and has a submit button

Back

return someVarDeclaredInFunction

Front

Code a statement that passes the value of a variable declared in the function to a global variable that was declared in the calling statement that resides in the main code.

Back

onFocus

Front

What is the keyword for detecting that the user has clicked in a field?

Back

global

Front

A variable declared in the main code is a ______ variable.

Back

2

Front

When the statement finishes executing, what is the value of performers? var group = "duo"; switch(group) { case "solo" : performers = 1; case "duo" : performers = 2; case "trio" : performers = 3; }

Back

<button onclick="myFunction()">Click me</button>

Front

code a button named "Click me" that calls myFunc function on click

Back

push ex: dogs.push("Clancy", "Hoover");

Front

What keyword adds one or more elements to the end of an array?

Back

value="Click"

Front

The code creates a button that says "Click". Fill in the blank. <input type="button" _________ onClick="myFunc();">

Back

switch(country) { case "Spain" :

Front

Code the first two lines of a switch statement that tests whether a particular string of your choice has been assigned to a particular variable of your choice.

Back

onSubmit

Front

What is the keyword for detecting that the user has submitted a form?

Back

1

Front

What is the result (in the console) of this statement? console.log(parseInt("1.6"));

Back

break;

Front

switch statement: What statement keeps all the statements below the true case from executing?

Back

< script src =" whatever.js" > </ script >

Front

what is the syntax for including an external javascript file?

Back

if (document.getElementById("pet").value === "dog") {

Front

Write the first line of an if statement. If what's in the field with the id of "pet" is "dog"....

Back

<input type="button" value="Say hi" onClick="alert('Hi');">

Front

Code a button that says "Say hi" along with a alert when clicked saying "Hi"

Back

default :

Front

Code the catch-all clause that specifies what happens if none of the above cases is true.

Back

onBlur="gone();">

Front

When the text field loses the focus, the function gone executes. Fill in the blank. <input type="text" ___________________________

Back

<input type="text" onFocus="myFunc();">

Front

Code a text field. When the user clicks in it, call a function.

Back

scope

Front

Global and local variables differ in their _______.

Back

<input type="text" onFocus="colorField();" onBlur="uncolorField();">

Front

Code a text field. When the user clicks in it, a function executes. When the field loses focus, a different function executes.

Back

Section 4

(50 cards)

<input type="text" id="age">

Front

Create a text field with the id "age"

Back

<html>

Front

What is the second level of the DOM? (lowercase)

Back

var links = keyParagraph.getElementsByTagName("a");

Front

Assign a list of links in the paragraph represented by the variable keyParagraph to the variable links, which hasn't been declared beforehand.

Back

var cells = t.getElementsByTagName("td");

Front

Get a list of the regular (non-header) cells in a table that has been assigned to the variable t. Assign the list of items to the variable cells, which hasn't been declared beforehand.

Back

function changeClass() { var biguns = document.getElementsByTagName("h1"); for (var i = 0; i < biguns.length; i++) { biguns[i].className += "myStyle"; } }

Front

Create a function called changeClass that will change the CSS class of all h1 elements

Back

if (married === false) { document.getElementById("status").value = "available"; }

Front

If the variable married is false, place the value "available" in the field with the id "status"

Back

document.getElementById(storedId).innerHTML = "212";

Front

Place a text value in a paragraph whose id is stored in a variable. Make up the variable

Back

<form onSubmit="myFunc('myField');">

Front

Write an opening tag for a form. When the form is submitted, a function is called. The id of a field is passed to the function. Make up the id.

Back

document

Front

In one word, what is the top level of the DOM?

Back

element

Front

What type of node do you see first here? <div> <h3>Age-old problem</h3> <p> So many nodes, so little time. </p> </div>

Back

document.getElementById("foo").innerHTML = "";

Front

Clear a paragraph. Make up the id.

Back

var bigHeads = document.getElementsByTagName("h1");

Front

The statement assigns a collection of h1 headings in a document to the variable bigHeads, which hasn't been declared beforehand. Code it.

Back

nodes

Front

People are the units of a company organization chart. What are the units of the DOM?

Back

var foo = document.getElementById("myField").value;

Front

Assign the value in a field with an id of your choice to a variable, which hasn't been declared beforehand.

Back

function imgSwapper(id, img) { var myImg = document.getElementById(id); myImg.src = img; }

Front

Code a function that assigns a new image source to an image element. The ID of the image element is the first parameter. The path to the image source is the second parameter. First assign the image element to a variable that hasn't been declared beforehand. Then assign the new image path to that variable.

Back

contentDiv

Front

The statement makes a collection of all the paragraphs in the div represented by the variable contentDiv and assigns the collection to pgraphs. Fill in the blank. var pgraphs = ________getElementsByTagName("p");

Back

if (document.getElementById("myField").value === "some text") {

Front

Code the first line of an if statement that tests for a text value of your choice in a field.

Back

DOM

Front

What is the three-character designation for the organization chart of a web page?

Back

.getElementsByTagName

Front

The statement makes a collection of all the divs in the document. Fill in the blank. var divs = document______________("div");

Back

document.getElementById("p1").innerHTML = document. getElementById("field1").value;

Front

Place the value found in a field into a paragraph. Make up the ids.

Back

var foo = contentDiv.getElementsByTagName("img");

Front

The statement makes a collection of all the images in the div represented by the variable contentDiv and assigns the collection to pics. Fill in the blank.

Back

<img src="foo.gif" id="bar" onClick="foobarred();">

Front

Code the tag for an image that, when clicked on, executes a function. Code in this order: image source, id, event handler.

Back

classPic.src = "pic2.gif";

Front

Assign the source "pic2.gif" to the element represented by the variable classPic.

Back

document.getElementById("foo").value = "3";

Front

using javascript (not HTML) put a value in a text field with an id of foo

Back

for (var i = 0; i <= 2; i++) { contents[i] = paragraphList[i].innerHTML; }

Front

Code a for loop that cycles through the first 3 paragraphs of a list, which has been assigned to an array of your choosing, and assign the text contents of each paragraph to an array item. Use the common loop specifications. This statement creates the array that collects the text contents: var contents = [];

Back

5 div, h3, heading text, p, paragraph text

Front

Assuming the DOM has been cleaned of junk artifacts, how many nodes are in this markup? (Answer with a numeral.) <div> <h3>Age-old problem</h3> <p> So many nodes, so little time. </p> </div>

Back

e.className += " special"; //note the space

Front

To any classes that are already assigned to the element represented by the variable e, add the class "special".

Back

imgLst[0];

Front

The statement assigns the first item of imgLst to firstPic. Fill in the blank. var firstPic = __________

Back

don't use += when assigning a className to the element, instead use =

Front

if you want to remove all other className assignments to an element in favor of a new className called "foo"

Back

Setting the value is normally used for input/form elements. innerHTML is normally used for div, span, td and similar elements.

Front

Under what conditions do you use getElementById("foo").value = "hello"; vs the innerHTML property?

Back

<img src="ford.jpg" id="car" onClick="swap(id, 'bmw.jpg');">

Front

Write the markup for an image with the source "ford.jpg" and the id "car". When the user clicks on it, a function, swap, is called. The markup passes the id and the image to insert, "bmw.jpg" as arguments, in that order. Write in this order: source, id, event handler.

Back

3

Front

How many element nodes do you see in this markup? (Answer with a numeral.) <div> <h3>Age-old problem</h3> <p> So many nodes, so little time. </p> </div>

Back

var pClass = pgraph.className;

Front

The element has been assigned to the variable pgraph. Assign its class to the variable pClass, which hasn't been declared beforehand.

Back

th

Front

what is the tag name of a header cell in an html table?

Back

.src = "after.png";

Front

The existing image is replaced by "after.png". Fill in the blank. document.getElementById("pic1")________________

Back

head and body

Front

Name the levels under the html level of the DOM. (lowercase)

Back

document.getElementById("p60").className += " special";

Front

Assign the class "special" to the paragraph with the id "p60"

Back

className

Front

What is the html element property that can be used to modify the appearance of the html element?

Back

document.getElementById("age").value = "";

Front

Clear a field with an id of "age"

Back

<form onSubmit="chkForm();">

Front

Write an opening form tag. When the form is submitted, the function chkForm is called.

Back

document.getElementById(picId).src = "nextPic"; //remember not to quote the elementId since its passed in.

Front

The first line of the function is... function swap(picId, nextPic) { The function substitutes the image represented by nextPic for the original image that has an id represented by picId. Code the line that makes the swap. Include the indent.

Back

src

Front

What property of an image element do you change if you want to swap the image with another

Back

for (var i = 0; i < oList.length; i++) oList[i].className = " myStyle"; }

Front

Code a for loop that cycles through the first 3 elements of a list, which has been assigned to a variable, and assign a class to each of them. Use the most common loop specifications.

Back

document.getElementById("paragraph1").className += " formal"; where there is a space between the quote and formal ... " formal" .. not "formal"

Front

Enter what's missing here. document.getElementById("paragraph1").className += "formal";

Back

+=

Front

The class "formal" is added to any existing classes assigned to the element. Fill in the blank. document.getElementById("paragraph1").className __ " formal";

Back

var bigHeads = document.getElementsByTagName("h1");

Front

The statement assigns a collection of h1 headings in a document to the variable bigHeads, which hasn't been declared beforehand. Code it.

Back

var txt = document.getElementById("div1").innerHTML;

Front

Assign the contents of the div with the id "div1" to the variable txt, which hasn't been declared beforehand.

Back

text

Front

What type of node is the fifth one you see here? <div> <h3>Age-old problem</h3> <p> So many nodes, so little time. </p> </div>

Back

<form onSubmit="chkForm();">

Front

Write an opening form tag. When the form is submitted, the function chkForm is called.

Back

var p = document.getElementById("slide0"); p.src = "cat.jpg";

Front

Assign the element with an id of "slide0" to the variable p, which hasn't been declared beforehand. Assign "cat.jpg" to the element as its source.

Back

Section 5

(50 cards)

3

Front

If the node is a text node, what is the value of nType? var nType = targetNode.nodeType;

Back

God.

Front

var body = document.getElementsByTagName("body"); var b = body[0]; what is the value of: b.childNodes[1].childNodes[2].innerHTML <div id="d1"> <p>Don't tell me.</p> <p>Let me guess.</p> </div> <div id="d2"> <p>Oh.</p> <p>my.</p> <p>God.</p> </div>

Back

1

Front

If the node is an element node, what is the value of nType? var nType = targetNode.nodeType;

Back

Parent, child, siblings 1st child of, 2nd child of and so on

Front

How do we specify node relationships to other nodes?

Back

nodeName

Front

what keyword do we use to determine if a node is a link, button, image, etc?

Back

var nodeVal = tNode.nodeValue;

Front

Get the value of the text node assigned to the variable tNode and assign it to the variable nodeVal, which hasn't been declared beforehand.

Back

.childNode[0]; or .firstChild;

Front

The target is the first child of the body, which has been assigned to the variable b. Fill in the blank. var e = b_________________

Back

b.childNodes[1].childNodes[3];

Front

The target is the fourth child of the second child of the body. The body has been assigned to the variable b. Fill in the blank. var e = _________________________

Back

if (e.hasAttribute("class") === false) { e.setAttribute("class", "misc"); }

Front

If the element assigned to the variable e doesn't have a class, set its class to "misc".

Back

attribute

Front

In the markup below src="http://www.wikipedia.org" is an _______ of the element img. <img src="http://www.wikipedia.org">

Back

Array of childNodes

Front

What data type does this return - assuming n is a node in the DOM? var foo = n.childNodes;

Back

<body>

Front

Type the opening tag for the last required element node.

Back

pic1.setAttribute("src", "next-image.png");

Front

Give an image that has been assigned to the variable pic1 a new source, next-image.png, by manipulating an attribute.

Back

childNodes

Front

Fill in the blank to make a collection of the nodes one level below the node represented by pNode. var nodeList = pNode.______;

Back

document.createElement("DIV");

Front

Create a simple DOM DIV

Back

var list = document.getElementById("p3").childNodes;

Front

In a single statement, make a collection of nodes one level down from an element with the id "p3". Assign the collection to a variable, list, which hasn't been declared beforehand.

Back

var ad = document.getElementById("info").getAttribute("href");

Front

In a single statement, find out the address of a link whose id is "info" and assign it to the variable ad, which hasn't been declared beforehand.

Back

if (nodeToCheck.nodeName === "#text") { var content = nodeToCheck.nodeValue; }

Front

Check the name of the variable nodeToCheck to see if it's a text node. If so, get its text content (value) and assign it to the variable content, which hasn't been declared beforehand.

Back

text

Front

Some browsers interpret whitespace in markup as nodes. What type of nodes are they?

Back

some browsers treat it as text nodes.

Front

Why is it important to be aware of white space in the markup?

Back

<p>

Front

Assuming that junk artifacts have been cleaned from the DOM, what is the second child of the first element node? <div> <h3>Age-old problem</h3> <p> So many nodes, so little time. </p> </div>

Back

Hello nodeValue

Front

We want the value of the first child of the p element <p>Hello<strong>world</strong></p> what is that value and what keyword would get it?

Back

<p >Hello world!</p >

Front

Revise this markup to eliminate whitespace but keep on 3 lines (in the markup) <p> Hello world! </p>

Back

using the working down notion.... var dTitle = document.firstChild.firstChild.firstChild. firstChild.nodeValue; or var dTitle = document.childNodes[0].childNodes[0].childNodes[0]. childNodes[0].nodeValue; var dTitle = document.head.childNodes[0];

Front

Working your way down the DOM hierarchy, get the value of the document's title text and assign it to the variable dTitle, which hasn't been declared beforehand. (In this document the title is the first child of the head.)

Back

if (targetNode.nodeValue === null) {

Front

Code the first line of an if statement that tests if the value of the node assigned to the variable targetNode is null.

Back

document.getElementById("p3").setAttribute("class", "special");

Front

In a single statement, assign to an element with the id "p3" the class "special".

Back

dNode.hasAttribue("attributeName");

Front

what keyword do we use to find whether a DOM node has an attribute of one kind or another?

Back

var child2 = document.getElementById("d2").childNodes[1].nodeName;

Front

In a single statement get the name of the second child of an element with the id "d2" and assign it to the variable child2, which hasn't been declared beforehand.

Back

var pgraphText = d.childNodes[1].innerHTML;

Front

Get the text content of the second child of the div represented by the variable d and assign it to the variable pgraphText, which hasn't been declared beforehand

Back

if (document.getElementById("p3").childNodes[0]) {

Front

Code the first line of an if statement that tests whether an element with the id "p3" has any child nodes by testing whether it has a first child node.

Back

var child2 = document.getElementById("d2").childNodes[1].nodeName;

Front

In a single statement get the name of the second child of an element with the id "d2" and assign it to the variable child2, which hasn't been declared beforehand.

Back

if (targetNode.nodeValue === null) {

Front

Code the first line of an if statement that tests if the value of the node assigned to the variable targetNode is null.

Back

#IMG

Front

In the markup below what is the node name of the element? (Pay attention to the case.) <img src="http://www.wikipedia.org">

Back

null Unlike a text node, the node value of an element is always null.

Front

In the markup below, what is the node value of the element? <img src = "http://www.wikipedia.org">

Back

text

Front

What type of node has no children?

Back

var c1 = d.childNodes[0]; var t = c1.nodeType;

Front

Assign the first child of the div represented by d to the variable c1. Assign the node type of the child to the variable t. Neither c1 nor t has been declared beforehand.

Back

equal sign. item on left is attribute name, on right is value <input type="text" <div id="d1"

Front

To find DOM attributes, what do we look for in the markup?

Back

for (var i = 0; i < p.childNodes.length; i++) if (p.childNodes[i].nodeType === 1) { break } }

Front

Write a for loop that checks to see if the next child of a parent represented by a variable p is an element node. If it is, break out of the loop. Begin by assigning the number of children of the parent to a variable, which hasn't been declared beforehand. Use the variable to limit the number of loops. Use the most common loop specifications.

Back

#text

Front

What is the node name of the first child of the element? <p>Hello world!</p>

Back

document element text

Front

name at least 3 types of nodes in the DOM

Back

var foo = p.childNodes.length;

Front

Find the number of children of a parent represented by the variable p and assign it to a variable that hasn't been declared beforehand.

Back

var nodeVal = tNode.nodeValue;

Front

Get the value of the text node assigned to the variable tNode and assign it to the variable nodeVal, which hasn't been declared beforehand.

Back

var numChildren = p.childNodes.length;

Front

Find the number of children of a parent represented by the variable p and assign it to a variable that hasn't been declared beforehand.

Back

document

Front

What node in the DOM has no parent?

Back

3 2 text nodes plus the <em> element

Front

If the children of the paragraph are assigned to kids, what is the value of kids.length? (Answer with a numeral.) <p>This is <em>very</em> important!</p>

Back

document

Front

in the DOM, What type of node contains all other nodes?

Back

IMG

Front

In the markup below what is the node name of the element? (Pay attention to the case.) <img src="http://www.wikipedia.org">

Back

var nType = tNode.nodeType;

Front

Get the node type of the node assigned to the variable tNode and assign it to the variable nType, which hasn't been declared beforehand.

Back

null unlike a text node the nodeValue of an element is always null.

Front

In the markup below, what is the node value of the element? <img src = "http://www.wikipedia.org">

Back

Hello

Front

Fill in the blank. The value of the first child of the first element is "______" <p>Hello<strong> world!</strong></p>

Back

Section 6

(50 cards)

d1.insertBefore(p1, d1.firstChild);

Front

i want to insert a new paragraph into a div that already has 5 paragraphs. I want the new paragraph inserted between the 2nd and 3rd paragraph. What is the syntax used to do this? div is represented by d1 new paragraph represented by p1

Back

constructor

Front

A function that creates objects and their properties is known as a _______ function.

Back

parentNode.removeChild(badNode);

Front

Remove a node represented by a variable of your choosing from a parent represented by another variable of your choosing.

Back

function person(first, last, age, eye) { this.firstName = first; this.lastName = last; this.age = age; this.eyeColor = eye; } var myFather = new person("John", "Doe", 50, "blue"); var myMother = new person("Sally", "Rally", 48, "green");

Front

Write a constructor function for a person

Back

if (document.getElementById("e1").attributes[1]. nodeName !== "class") {

Front

Code the first line of an if statement that tests whether the second attribute of an element with the id "e1" is not class.

Back

var dog = { name: "boone", breed: "hound" };

Front

create a dog object with name and breed properties

Back

txt.appendChild("moreTxt");

Front

Add a text node represented by a variable of your choosing to a parent represented by another variable of your choosing.

Back

a way to share a method or property across multiple objects

Front

what is a prototype?

Back

createTextNode

Front

What is the keyword for creating a string that will be the child of a paragraph?

Back

calcObvious: function () {

Front

in an object without prototypes, Code the first line of a method, calcObvious.

Back

setAttribute("class", "pretty");

Front

What is the keyword for adding class = "pretty" to an image tag? You want to eliminate all other classes in the class collection.

Back

var newText = document.createTextNode("Bada-bing");

Front

Create a text node with the string "Bada-bing" and assign it to the variable newText, which hasn't been declared beforehand.

Back

createElement("div");

Front

What is the keyword for creating a new div?

Back

var foo = { myNum: 2, myMethod: function() { return this.myNum * 10; } };

Front

Code an object that has one property, a number, and one method. The method multiplies the property by 10 and sends the result back to the calling code. Don't refer to the object by name in the method.

Back

appendChild

Front

What is the keyword for adding text content to a paragraph?

Back

node2.nextSibling

Front

When the following statement executes, what node comes before cNode? pNode.insertBefore(cNode, node2.nextSibling);

Back

parentNode.removeChild(parentNode.lastChild);

Front

In a single statement, eliminate the last node one level down from the element represented by parentNode.

Back

myMethod: function(parm1, parm2) {

Front

Code the first line of a method with 2 parameters.

Back

prototype

Front

What is the keyword that allows all objects created by a particular constructor to share the same property or function?

Back

var nam = target.attributes[1].nodeName;

Front

Get the name of the second attribute of an element that has been assigned to a variable of your choosing, and assign the name to another variable of your choosing, which hasn't been declared beforehand.

Back

this.

Front

The method definition in a constructor has three features that a one-off literal definition doesn't have. Two of them are = in the definition and ; after the closing curly bracket. What is the third feature? (5 characters)

Back

they are handy when we need a template for creating objects.

Front

what is the purpose of a constructor function?

Back

ConstructorFunctionName.Prototype.NameOfSharedFunction Person.prototype.calcAge = function() { //code here };

Front

how do we create a new prototype

Back

method

Front

A function that's attached to an object is known as a _______.

Back

var foo = document.createElement("div");

Front

Create a div and assign it to a variable of your choosing, which hasn't been declared beforehand.

Back

attributes

Front

Fill in the blank to make a collection of attributes and assign it to attList. var attList = targetNode.___________;

Back

property

Front

What do you call a value that is attached to an object? (one word)

Back

Part.prototype.brand = "Acme";

Front

Code a prototype property called brand for a constructor called Part. Its value is "Acme"

Back

prototype

Front

This is the first line of a prototype statement that creates a prototype method for the constructor MakeObj. Fill in the blank. MakeObj.________.calcTax = function(price) {

Back

var newP = document.createElement("p"); var newT = document.createTextNode("Hello world"); newP.appendChild(newT); parentElement.insertBefore(newP, existingE);

Front

Create a paragraph node. Create a text node with content of your choosing. Add it to the paragraph node. Insert it before a node represented by a variable of your choosing, under a parent represented by a variable of your choosing.

Back

this.addTaxTo = function(price) {

Front

Rewrite this line so it'll work in a constructor function. addTaxTo: function(price) {

Back

constructor

Front

When you see this line of code, you know it's part of a _______ function. this.doSomething = function() {

Back

pNode.insertBefore(newOne, existing.nextSibling);

Front

Using variables of your choosing, insert a new node after an existing node that has been targeted and assigned to a variable.

Back

pNode.insertBefore(newOne, existing.nextSibling);

Front

Using variables of your choosing, insert a new node after an existing node that has been targeted and assigned to a variable.

Back

var att1 = document.getElementById("e").attributes[0].nodeName;

Front

In a single statement, assign the name of the first attribute of an element with the id "e" to the variable att1, which hasn't been declared beforehand.

Back

lot31.size;

Front

The object is lot31. One of its properties is size. How do you refer to the property in code?

Back

newLink.setAttribute("href", "http://www.wikipedia.org");

Front

A new <a> node has been created and assigned to the variable newLink. Add an attribute to it that takes the user to wikipedia.org when clicked.

Back

parentNode.removeChild(parentNode.lastChild);

Front

In a single statement, eliminate the last node one level down from the element represented by parentNode.

Back

var nonentity = { doNothing: function() { } };

Front

Code an object that has a single method that doesn't do anything.

Back

node2

Front

The statement inserts the node represented by cNode before the child represented by node2. The parent node is represented by pNode. Fill in the blank. pNode.insertBefore(cNode, _______);

Back

var ad = document.getElementById("info").getAttribute("href");

Front

In a single statement, find out the address of a link whose id is "info" and assign it to the variable ad, which hasn't been declared beforehand.

Back

var greeting = { sayHi: function() { alert("Hello world!"); } };

Front

Code an object that has a single method that displays an alert with a text message.

Back

pNode.insertBefore(newE, pNode.childNodes[2]);

Front

In a single statement insert a new element represented by newE before the third child of the parent pNode.

Back

if (document.getElementById("e1").attributes[1]. nodeName !== "class") {

Front

Code the first line of an if statement that tests whether the second attribute of an element with the id "e1" is not class.

Back

if (e.hasAttribute("class") === false) { e.setAttribute("class", "misc"); }

Front

If the element assigned to the variable e doesn't have a class, set its class to "misc".

Back

function() {

Front

This is the first line of a prototype statement that creates a prototype method for the constructor Product. The method has no parameters. Fill in the blank. Product.prototype.totalCosts = _____________

Back

var numAtts = document.getElementById("pic29").attributes.length;

Front

In a single statement get the number of attributes of an element with the id "pic29" and assign the number to the variable numAtts, which hasn't been declared beforehand.

Back

this.doSomething = function() {

Front

Rewrite this snippet so that it can be used for a constructor function. doSomething: function() {

Back

var newE = document.createElement("a"); newE.setAttribute("href", "http://www.bees.com"); parentElement.insertBefore(newE, existingE);

Front

Create an <a> node. Make it link to "bees.com". Insert it before a node represented by a variable of your choosing, under a parent represented by a variable of your choosing.

Back

onclick note the value returns all lower case.

Front

Look at the following markup and the code that follows it, and tell me the value of nam. Include the quotation marks. <p id="p1" class="regular" onClick="disappear();"> var nam = document.getElementById("p1"). attributes[2].nodeName;

Back

Section 7

(50 cards)

""

Front

What 2 characters are missing? var isPropertyOf = size in thing;

Back

()

Front

In addition to history, a dot, and a semicolon at the end, there are 2 characters that are always part of a statement that moves the browser backward and forward. Type the characters in the order in which they appear.

Back

"www.google.com"

Front

http://www.google.com/microsoft Look at the URL shown above and tell me the value of currentSite. It's a string, so enclose it in quotes. var currentSite = window.location.hostname;

Back

function myFunction() { var x = document.createElement("STYLE"); var t = document.createTextNode("body {font: 20px verdana;}"); x.appendChild(t); document.head.appendChild(x); }

Front

create a function that places a style element in the head and makes all text in the body 20px verdana

Back

if (plan2.hasOwnProperty("color")) {

Front

Code the first line of an if statement that tests whether the property "color" was explicitly assigned to an object as opposed to inherited.

Back

info.document.write(content);

Front

An HTML string has been assigned to the variable content. Load the string into a window whose handle is info.

Back

history.go(2);

Front

Direct the browser to skip 2 URLs ahead. )

Back

"#2"

Front

http://www.microsoft.com/default.html#2 Look at the URL shown above and tell me the value of pageSection. It's a string, so enclose it in quotes. var pageSection = window.location.hash;

Back

Bar.prototype.method = function(e) { this.alert(e); }

Front

Bar.prototype.method = function(e) { this.alert(e); }

Back

window.location.reload(false); the word false is not mandatory... its the default if no parameter given.

Front

Code a statement that explicitly, using a Boolean, tells JavaScript to refresh the current page from the cache if the page is cached.

Back

"/en-us/windows/gaming"

Front

https://www.microsoft.com/en-us/windows/gaming Look at the URL shown above and tell me the value of currentPage. It's a string, so enclose it in quotes. var currentPage = window.location.pathname;

Back

name

Front

What is the second parameter of the window.open method? Answer with one word.

Back

var foo = document.write("hello.html");

Front

Open a document, loading an html file that shares the same host and subdirectory as the original document.

Back

backspace

Front

What keypress has the same effect as history.back()? Answer with lower-case characters.

Back

product332.caseQty = 6;

Front

There is a prototype property, caseQty, for the constructor Product. Its value is 12. Make an exception for product332. Its caseQty is 6.

Back

MakeObj.prototype.dispMess = function(message) { alert(this.message); };

Front

Code a method prototype that displays a message. The message text is passed to the method by the constructor, not the statement that calls the method.

Back

page1.html

Front

The browser is on page1.html. There is no history. The statement history.go(-1)executes. What page does the browser land on?

Back

MakeObj.prototype.dispMess = function(message) { alert(message); };

Front

Code a method prototype that displays a message. The message text is passed to the method by the statement that calls the method, not by the constructor.

Back

handle

Front

what do you call the item on the left of equals sign? var foo = window.open();

Back

hi.document.write("<h1>Hello world!</h1>");

Front

Fill a window whose handle is hi with an h1 head that says "Hello world!"

Back

space - window names (second parameter) cant have spaces.

Front

what is the illegal character here? var newWin = window.open("", "My Window");

Back

in

Front

what keyword is used to determine if an object has a property?

Back

if (obj.hasOwnProperty("color") {

Front

Code the first line of an if statement that tests whether the property "color" was explicitly assigned to an object as opposed to inherited.

Back

var theProps = []; for (var prop in dog) { theProps.push(prop); }

Front

How would you assemble an array of properties (theProps) for an object named dog?

Back

var popup = window.open("offer.html");

Front

Open a new window on the current site whose handle is popup and whose document is offer.html.

Back

reload

Front

The statement refreshes the current webpage. Fill in the blank. window.location.________();

Back

assign

Front

The current page is to be included in the browser history when the new page loads. Fill in the blank. window.location._______("http://www.wow.com");

Back

var foo = window.open(); foo.close();

Front

Open a blank window, then close it.

Back

var pop = window.open(newDocument);

Front

Open a window, loading a document that's represented by a variable.

Back

true window.location.reload(true);

Front

What word forces the browser to reload the page from the server?

Back

window.open();

Front

A full-size blank window will open. Complete the code. var greatBigWindow = ____________

Back

replace

Front

The current page is to be excluded from the browser history when the new page loads. Fill in the blank. window.location._______("http://www.wow.com");

Back

window.location.assign("http://www.me.com");

Front

Using assign, direct the browser to me.com.

Back

history

Front

What word is used in all statements that move the browser backward and forward?

Back

var c = "b" in a;

Front

Code a statement that tests whether the object a has a property b, and assign the result to the variable c, which hasn't been declared beforehand.

Back

faq.close();

Front

Close a window whose handle is faq

Back

function MakeObj(color) { this.color = color; } var thing = new MakeObj("blue"); MakeObj.prototype.displayColor = function() { alert(this.color); }; thing.displayColor();

Front

Code a constructor function that creates an object with one property. Call the function to create an object, passing a value for the property. Code a prototype method that displays the object's property. Call the method

Back

document.write("<h1>my new page</h1>");

Front

how do you replace all the nodes of a html page in one fell swoop?

Back

window.location.replace("http://www.foo.com");

Front

Code a statement that directs the browser to a new URL (make up the name) and excludes the current page from the browser history.

Back

window.location.assign("http://www.whee.com"); ...or... window.location.replace("http://www.whee.com");

Front

Code either of the alternatives taught in this module that you can use instead of... window.location.href = "http://www.whee.com";

Back

pop.document.write("<p>Whee!</p>");

Front

Display a paragraph with text content "Whee!" in a window that's already open, whose handle is pop.

Back

MakeObj.prototype.dispMess = function(message) { alert(message); };

Front

Code a method prototype that displays a message. The message text is passed to the method by the statement that calls the method, not by the constructor.

Back

document.createElement("STYLE");

Front

What is the syntax for creating a css style element in javascript?

Back

What is the window.location object?

Front

The location object contains information about the current URL, and is part of the window object and is accessed through the window.location property.

Back

function MakeDog() { } MakeDog.prototype.doNothing = function() { };

Front

Code an empty constructor function. Then give it a prototype method that has no parameters and does nothing.

Back

if ("prop" in obj) {

Front

Code the first line of an if statement that checks to see if an object has a particular property.

Back

Direct the browser to wow.com. Exclude the current page from the browser history.

Front

window.location.replace("http://"www.wow.com");

Back

var pop = window.open(newDocument);

Front

Open a window, loading a document that's represented by a variable.

Back

MakeObj.prototype.dispMess = function() { alert(this.message); };

Front

Code a method prototype that displays a message. The message text is passed to the method by the constructor, not the statement that calls the method.

Back

increases speed and reduces size of objects since there is no redundant code

Front

Why have method or property Prototypes

Back

Section 8

(31 cards)

onSubmit

Front

for elements that belong to forms, what is the keyword that typically calls a function to validate?

Back

adddlert is not defined

Front

try and catch what will this code return? try { adddlert("Welcome guest!"); } catch(err) { document.getElementById("demo").innerHTML = err.message; }

Back

var el = document.getElementById("p1"); el.onmouseover = doIt;

Front

Assign an element with an id of your choice to a variable of your choice. When the user mouses over the element, run a function with a name of your choice.

Back

pixels

Front

In size and position parameters, what do the numbers represent? Answer with one word.

Back

get the element and define its event with lowercase - otherwise wont work.

Front

what is the rule when defining the event with code rather than the in-line approach? eg in-line = <input type="button" id="btn1" onClick="doThis();">

Back

option value select element inside a form <form onsubmit="return checkForSelection();"> <select id="states"> <!--<option value ="" selected ="selected"> SELECT A STATE </option> --> <option value="AL"> Alabama </option> <option value="AK"> Alaska </option> <option value="AZ"> Arizona </option> <option value="AR"> Arkansas </option> </select> <input type="submit" value="Submit Form"> </form>

Front

when collecting values via dropdown, what html elements do we use?

Back

if (val.indexOf(".") - val.indexOf("@") < 2) {

Front

Code the first line of an if statement that tests whether there is not at least one character separating the "@" and the dot in the string represented by a variable.

Back

undefined variables

Front

The try...catch approach is mainly useful for spotting ________. Answer with two words.

Back

if (targetField.value.length === 0) { alert("Please enter something"); return false; }

Front

This is the first line of code that displays an alert if the field is empty, and cancels the form submission. Write 4 more lines to complete it. var targetField = document.getElementById("f1");

Back

.getAttribute('name')

Front

what is the javaScript syntax to get an attribute of a node? A. .attr('name') B. .getAttribute('name')

Back

var style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = '.cssClass { color: #F00; }'; document.getElementsByTagName('head')[0].appendChild(style); document.getElementById('someElementId').className = 'cssClass';

Front

create a css class using javascript named 's' apply that style to all list items on a page

Back

<form onSubmit="return validate();">

Front

Write the opening tag for a form that executes a validation function, validate, when the form is submitted

Back

• global vars at top • functions together • local vars at top of function • Variable and function names written as camelCase • Global variables written in UPPERCASE (We don't, but it's quite common) • Constants (like PI) written in UPPERCASE //see http://www.w3schools.com/js/js_conventions.asp

Front

Name at least 5 generally accepted javascript coding conventions...

Back

ID

Front

If I plan to validate this field, targeting it in the most common way, what's missing? Answer with one word, in upper-case. <input type="text">

Back

onclick

Front

When the button represented by b1 is clicked, the function is called. Fill in the blank. b1.______ = doSomething;

Back

var w = window.open("", "", "width=300,height=200,left=100,top=50");

Front

Open a new window, newWin, with a blank URL and name, and parameters for (in this order) size across, size up and down, distance from the side, and distance from the top. The parameters are 300, 200, 100, and 50.

Back

document.getElementById("lnk").onclick = doIt;

Front

In a single statement convert this markup to scripted event-handling. <a href="JavaScript:void(0)" onClick="doIt()" id="lnk">Click</a>

Back

selectedValue

Front

In the markup for a selection box, the ID is assigned to...

Back

myImg.onmouseout = foo;

Front

When the user moves the mouse off an image represented by a variable of your choice, a function with a name of your choice executes.

Back

this is like hitting the back button. goes back 1

Front

what does this code do? window.history.go(-1);

Back

100

Front

What is the minimum number of pixels in the width and height parameters? Answer with a numeral.

Back

return <form onSubmit="return validateMe();">

Front

If I plan to validate this form, what's missing from this markup? <form onSubmit="validateMe();">

Back

f1.onsubmit = myFunction;

Front

you have a form element f1. write a click event to call a function

Back

document.getElementById("b1").onclick = sayHi;

Front

In a single statement convert this markup to scripted event-handling. <input type="button" value="Click to be greeted" id="b1" onClick="sayHi();">

Back

B. attributes

Front

what is the syntax for getting all the attributes of a given node? A. getAttribute B. attributes

Back

if (addr.indexOf(".") < addr.length - 2) {

Front

Code the first line of an if statement that tests whether there are at least 2 characters after the dot in a string represented by a variable. Use the length of the variable to measure. Dont use regular expressions.

Back

if (document.getElementById("field1").value.length === 0) {

Front

Code the first line of an if statement that tests whether the field with an ID of field1 is empty.

Back

doSomething

Front

When the button represented by b1 is clicked, the function doSomething is called. Fill in the blank. b1.onclick = ________; Note: use pure javascript not html

Back

value

Front

When validating text boxes in fields that must be filled out, what property of the text box element do we typically check? One word.

Back

var a = ['how', 'now', 'brown', 'cow', 'farm', 'animals' ]; filterBy = 'ow' filterBy ? a.filter((a) => a.indexOf(filterBy) !== -1) : a;

Front

Given an array var animals = ['dog', 'cat', 'cow', 'moose', 'duck', 'crow' ]; create a function that returns an array of elements that is filtered by an input parameter for example ... if the function receives 'ow', it will return ['cow','crow']

Back

<form id="frm1" onSubmit="return val();">

Front

Write the opening tag for a form whose id is "frm1" that executes a validation function, val, when the form is submitted.

Back