Unit 1 Flashcards

1
Q

How To: Open a box that says Hello, world!

A

alert (“Hello,world.”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What Are The Steps in Program Development?

A
  1. Define the problem
  2. Outline the solution
  3. Develop the outline into an algorithm
  4. Test the algorithm for correctness
  5. Code the algorithm into a specific programing language working in “versions”
  6. Run the latest “version” of the program on the computer
  7. Document and maintain the program
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you define the problem?

A
  1. Input variable list
  2. processing checklist
  3. output variable list
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you Outline the Solution?

A
  1. the major processing steps
  2. the major subtasks
  3. the user interface
  4. the major control structures
  5. the major variables and record structures
  6. the mainline logic
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the unit of indentation for JavaScript?

A

Four Spaces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

If a line of code is too long to fit on one line of the text editor, what unit of indentation must the continuation of the line be?

A

Eight Spaces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the maximum number of characters to use on a JavaScript line?

A

80 Characters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the comments that we need to use in this class?

A
  1. Our Name, Section and email at the top of our labs.
  2. A comment line at the start of each section within a program. These section comment lines must start with a verb. (Describing an action)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are Semicolons used for in JavaScript?

A

To terminate a statement.

var firstName="Fred";
document.write(firstName);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Every Simple Statement must end with a semicolon, true or false?

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Every simple statement must be on its own line, true or false?

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

When should you use blank lines?

A
  1. After each section of your program.
  2. Most operators must have a space above and below
  3. A space should follow every comma “,”

// Operator spacing

    var firstName = "Fred";
    var errorCount = 0;
errorCount += 3;

enteredNumbersSum = numberOne + numberTwo;
    // Note: The three exceptions to this rule are for the dot "." ,
    // the "++", and the "--" operators.
loopCounter++;                 // no space around the ++
loopCounter--;                 // no space around the --
document.write("Hi Parent");   // no space around the dot
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is JavaScript?

A
  1. JavaScript is an interpreted programing language.

2. There is a full computer program inside each browser that reads your JavaScript code and runs the code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is an “Interpreter”?

A

The full program within each browser that reads and runs the JavaScript code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the three rules that we are concerned with in this class?

A
  1. Syntax
  2. Convention
  3. Style
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the rule of syntax?

A

If a computer programing language enforces a rule then we call that rule “syntax”. This is the strongest level of rule. If you break this rule, the program will not run.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What rule is this?
If a computer programing language enforces a rule, this is the strongest level of rule. If you break this rule, the program will not run.

A

The rule of Syntax.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the rule of Convention?

A

If most users of a programing language all over the world do something the exact same way, it is called a “Convention”. Although the JavaScript language itself doesn’t care about these rules, if everyone is using them, there is a good reason for it. A professional follows convention.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What rule is this?
Something that users all over the world do the same. Although the JavaScript language does not care, there is usually a good reason for this and a professional will follow it.

A

The rule of Convention.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is the rule of Style?

A

There are many ways of structuring your code. The main thing is that you pick a method and stick with it. Be consistent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What rule is this?

There are many ways of structuring your code. The main thing is that you pick a method and stick with it. Be consistent.

A

The rule of Style.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Is JavaScript case sensitive?

A

yes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

True or False

JavaScript is not case sensitive.

A

False. JavaScript is case sensitive.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is White Space in JavaScript?

A
  • Space
  • Tab
  • Carriage Return (officially called the “line terminator”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What does RAM stand for?

A

Random Access Memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What Three things do computers do from our perspective?

A
  1. They get data into the program
  2. They process the data
  3. They output the data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What is RAM, Random Access Memory?

A

RAM is one long linear chain of bits. And a bit is a very simple thing, it’s just a 0 or a 1.

Think of each mark on the tape measure as a single bit.

Data is just a collection of bits in a known spot.

Say, starting at 5” on the tape measure and going for 10 marks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What is a variable?

A

Data within a program is stored in variables. From a software perspective, a variable is a container that holds references to data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What is a container that holds references to data.

A

A Variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

How many types of JavaScript statement are there?

A

2 types of JavaScript statements.

  1. A simple Statement
  2. A compound statement
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

What is a simple JavaScript statement?

A

A simple statement is simple:

x = 4;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

What is a compound statement?

A

A compound statement combines multiple levels of logic. An if/the/else conditional is a good example:

    if (something == 1) {
        //Some Code Here
    } else {
        //Some other code here
    }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

Triue or False, there are five JavaScript statement types.

A

False. There are Two Types of JavaScript statements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

True or False. A Compound statement is a simple statement.

A

False. A compound statements combines multiple levels of logic. Example would be an if then else statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

True or False, certain words are reserved in JavaScript, meaning that you can not use them as Variables, identifiers or constant names within your program.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

What are the words that are currently reserved in JavaScript?

A
break
case
catch
continue
debugger
default
delete
do
else
finally
for
function
if
in
instanceof
new
return
switch
this throw
try
typeof
var
void
while
with
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

What are the words that start with B that are reserved in JavaScript?

A

break

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

What are the words that start with C that are reserved in JavaScript?

A

Case
Catch
Continue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

What are the words that start with D that are reserved in JavaScript?

A

Debugger
Default
Delete
Do

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

What are the words that start with F that are reserved in JavaScript?

A

Finally
For
Function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

What are the words that start with I that are reserved in JavaScript?

A

If
In
Instanceof

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

What are the words that start with N that are reserved in JavaScript?

A

New

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

What are the words that start with R that are reserved in JavaScript?

A

Return

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

What are the words that start with S that are reserved in JavaScript?

A

Switch

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

What are the words that start with T that are reserved in JavaScript?

A

This
Throw
Try
Typeof

46
Q

What are the words that start with V that are reserved in JavaScript?

A

Var

Void

47
Q

What are the words that start with W that are reserved in JavaScript?

A

While

With

48
Q

How many words are currently reserved in JavaScript?

A

26

49
Q

How do you start a variable in JavaScript?

A

var

Start with the word var. This tells JavaScript to create a variable. The variable will be named by whatever set of characters follows. for example:

var count;

50
Q

Create a variable named birthday.

A

var birthday;

51
Q

Create a variable named count.

A

var count;

52
Q

Create a variable named count that has a value in it.

A

var count = 1;

“ = 1”
A space, an assignment operator, and the number 1

53
Q

What is a Prompt?

A

Prompt is a function/method of the window object.

The viewer is prompted to enter something into the text box that displays.

54
Q

What does the prompt( ) method do?

A

the program opens a small dialog box on the screen that contains:

  1. A (usually) short phrase asking the viewer to key in some information
  2. A text box into which a viewer will key in information
  3. An OK button for the viewer to click when he/she has keyed in the information
  4. A cancel button to close the dialog box without keying in anything
55
Q

Does the prompt() method return something back into the program itself?

A

Yes. It will return what the viewer keys in.

56
Q

Does the prompt() method require a variable to catch the returned information?

A

Yes.

You need to set a variable before the prompt and then use the variable in conjunction with the prompt.

var firstName;   //This would be up in the variable section of the program

firstName = prompt("Enter your first name");
57
Q

True or false: The prompt () method always returns a string, even when the viewer keys in just numerals.

A

True

58
Q

Break down the following:

document.write(“This is a string”)

A
  1. Document refers to the HTML page that contains the JavaScript program
  2. The period, called the dot, is a way to access things inside of your document.
  3. The word write is the method of the document object.
59
Q

Create a variable to print out your name.

A
var myName = "Jessica Page";
document.write(myName);
60
Q

Create a variable.

Prompt user for the variable and assign the resulting value to the variable you created.

output the variable to the page

A

var name;

var name = prompt(“What’s Your Name”);

document.write(name);

61
Q

Prompt user for var lastName; and assign the resulting value to the variable.

A

var lastName = prompt(“What’s your last name”);

62
Q

Output a single space with a document.write()

A

document.write(“ “);

63
Q

What are the data types in JavaScript?

A
  • Numbers
  • Strings
  • Booleans
  • Null
  • Undefined
  • Objects
64
Q

How many data types are there in JavaScript?

A

6

  • Numbers
  • Strings
  • Booleans
  • Null
  • Undefined
  • Objects
65
Q

What three Data Types will we be focusing on this semester?

A
  • Numbers
  • Strings
  • Booleans
66
Q

How do you declare a variable that is just a number?

A

Just declare a variable and put a number in it. Do not type the number with quotes.

var count = 1;
var price = 12.99;
67
Q

Is the following a variable using the Number data type?

var priceString = “12.99”;

A

No. Because it uses quotes.
A Number Variable is just declaring a variable with a number in it and no quotes.

var priceString = 12.99;

68
Q

Do we have to tell JavaScript that a variable is a number?

A

No.

69
Q

What is a string?

A

Anything entered into a computer by typing is a string.

70
Q

When a user is asked to enter a number in a prompt dialog, what data type comes into your program?

A

A string.

71
Q

Convert the following to a number.

var price;
price = prompt(“Enter a price.”);

A

price = Number(price);

72
Q

What does the Number() function do?

var price;
price = prompt(“Enter a price.”);
price = Number(price)

A

The number function takes the current string in the variable and converts it to a number if it can. Then our line of code puts the new number back into the price variable.

73
Q

True or False:
When data enters the program via the prompt() method, the keyed in digits need to be converted to numeric format via the Number() function.

A

True

74
Q

True or False:
When data enters the program via the prompt() method, the keyed in digits do not need to be converted to numeric format via the Number() function.

A

False.

var price;
price = prompt(“Enter a price.”);
price = Number(price)

The entered price (prompt) is a string.

Then it becomes a number, with the number function creating a string and the string being given to the number function.
price = Number(price)

75
Q

What symbol do we use for addition?

A

+

76
Q

What symbol do we use for subtraction?

A

-

77
Q

What symbol do we use for multiplication?

A

*

78
Q

What symbol do we use for division?

A

/

79
Q

True or False:

String are a series of characters surrounded by single or double quotes.

A

True

80
Q

What are strings?

A

Strings are a series of characters surrounded by double or single quotes.

81
Q

True or False:

If a string is surrounded by double quotes, you can have single quotes inside the string.

A

True.

82
Q

True or False:

If a string is surrounded by single quotes, you can have double quotes inside the string.

A

True

83
Q

True or False:

You can not have a string with single quotes inside double quotes.

A

False.

If a string is surrounded by double quotes you can have single quotes inside the string.

84
Q

True or False:

You can not have a string with double quotes inside single quotes.

A

False.

If a string is surrounded by double quotes, you can have single quotes inside the string.

85
Q

What is an escape character?

A

An escape character is a special character that is added with a preceding “"

86
Q

How would you add a backspace into a string?

A

\b

87
Q

What is \b if in a string?

A

backspace

88
Q

How would you add a tab to a string?

A

\t

89
Q

What is \t in a string?

A

tab

90
Q

What is \n in a string?

A

newline

91
Q

How would you add a newline in a string?

A

\n

92
Q

How would you add a single quote to a string?

A
\'
example: 
var output;
output = 'Here\'s a single quote.'
document.write(output);
93
Q

What is \f in a string?

A

Form Feed

94
Q

What is \r in a string?

A

Carriage Return

95
Q

What is \ in a string?

A

Literal backslash

96
Q

what is " in a string?

A

Double Quote

97
Q

What is ' in a string?

A

Single quote.

98
Q

How would you add a carriage return in a string?

A

\r

99
Q

How would you add a form field in a string?

A

\f

100
Q

How would you add a literal backslash in a string?

A

\

101
Q

How would you add a double quote in a string?

A

"

102
Q

How would you add a tab to a string?

A

\t
Example:
var outputOne;
var outputTwo;

outputOne = "one\tTwo\tThree\tFour";
outputTwo = "1\t2\t3\t4\t";

document. write(outputOne);
document. write(“<br></br>”);
document. write(outputTwo);

One Two Three Four
1 2 3 4

103
Q

What is a property?

A

A property is a characteristic of an object.

104
Q

What is the .length property?

A

it gives the length of a string:
Example:
var whatWillThisBe = “This is a string”.length;

The mystery variable is 16

105
Q

What is a “Method”?

A

Method refers to a pre-written program always used in conjunction with an “Object”.

106
Q

What is the alert() method tied to?

A

The alert() method is tied to the “window” object.

107
Q

What refers to a pre-written program that is always used in conjunction with an object?

A

A method.

108
Q

True or False:

Method refers to a pre-written program always used in conjunction with an “Object”.

A

True

109
Q

True or False:

Methods are not associated with Objects.

A

False.

A method is a pre-written program that is always associated with an “Object”.

110
Q

What are three of the simplest “Expressions”?

A
1. A string. (Text within quotes) 
alert("Hello World");
2. A number (No Quotes)
alert(123);
3. The Variable Name (No Quotes)
alert(firstName);
111
Q

Can you do mathematical operations in the alert() method?

A

Yes, but it is not recommended.

112
Q

How do you convert a string to a number while declaring the variable?

A

numberOne = Number(prompt (“What is a number?”));