Lesson 2: Writing Simple Scripts Flashcards

1
Q

What is each script known as?

A

A statement.

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

What should each statement end with?

A

A semi-colon ;

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

What are comments used for?

A

To explain what your code does.

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

Show a single line comment:

A

// single line comment

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

Show a multiple line comment:

A

/* multiple line comment */

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

What data types are there?

A
  • Number : 3-5
  • Boolean: true/false
  • Undefined
  • Null
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are variables used for?

A

To store information temporarily in order to complete certain tasks.

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

Declare a variable:

A
  • vair quantity; // prior ES6
  • let price; // variable
  • const ratio; // constant
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What type are Strings in JavaScript?

A

Primitive.

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

Use a string constructor to make a new string:

A

let str = new String(‘Hello’);

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

What does ‘Escaping’ mean?

A

Making a regular char after \ special and making a special char after \ literal.

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

Show escaping:

A

let question = ‘What/’s your name?’;

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

What does the string operator + symbol do?

A

Joins strings on either side of it.

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

Show concatenating strings:

A
let greeting = 'Hello';
let name = 'Bob'
let message = greeting + name;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are events?

A

The browser’s way of saying “Hey, this happened.”

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

What are Arithmetic Operations?

A

Addition, subtraction, multiplication and division.

17
Q

Show an Arithmetic Operation:

A

var theSum = 4 + 3;

18
Q

Show an Arithmetic Operation using variable names:

A
var productCount = 2;
var subtotal = 14.98;
var shipping = 2.75;
var total = subtotal + shipping;
19
Q

Show an example of Combining Operators:

A
price = price * uplift;
price*= uplift
20
Q

How to convert Celsius to Fahrenheit?:

A

var hTemp = cTemp*9/5 + 32;

21
Q

Write a code snippet converting Celsius to Fahrenheit:

A

var hTemp = cTemp *9/5 + 32;

document. write(“Temp in C: + cTemp + “degrees<br></br>”);
document. write(Temp in F + hTemp + “degrees”);

22
Q

What are three event handlers?

A

onClick, onMouseOver and onMouseOut

23
Q

What can the onClick event handler do?

A

Be applied to nearly all HTML elements.

24
Q

Show an example of an onClick event handler:

A
25
Q

What do the onMouseOver and onMouseOut event handlers used for?

A

When you want to detect where the mouse pointer is on the screen with a reference to a page element.

26
Q

Show an example of onMouseOver:

A

<img></img>