Beginner JavaScript Flashcards

1
Q

JavaScript runs in your web browser alongside HTML and CSS, and can be added to any web page using a _______ tag.

A

script

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

What are the three types of JavaScript included in HTML pages?

A
  1. ) Internal
  2. ) External
  3. ) Inline – Should be avoided
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the file extension used by JavaScript files?

A

js

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

Storing data so we can use it later is achieved with ______.

A

Variables

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

var surname = prompt(‘Greetings friend, may I enquire as to your surname?’);

A

Prompt the user to enter a surname and store the contents of that response in a variable named surname.

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

What are the two parts to a variable?

A

The variable’s name and value

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

What are the two steps to creating a variable?

A

declaration and initialization

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

What is the variable declaration?

A

Declaration is declaring a variable to exist.

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

What keyword is used to declare a variable?

A

var

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

What is Initialization?

A

Initialization is giving a variable its value for the first time.

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

What is a string?

A

A collection of letters. A string is surrounded by single or double quote marks.

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

What is assignment?

A

It looks very similar to initialization. You use the equals sign, but there’s no need for the var keyword because we’ve already declared the variable.

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

What capitalization convention does this variable name use: piecesOfFruit?

A

Camel casing

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

Mathematical symbols are called _______.

A

Operators.

+, -, *, /, %

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

When a comparison is made the outcome is either true or false; a special kind a of data called a _____. This is _____.

A

boolean and logic

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

What operator should be used to find out when two values are equal?

A

triple equals operator (“===”)

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

What operator should be used to find out when two values are NOT equal?

A

triple not equal operator (“!==”)

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

What operators are used to determine which value greater or less than another?

A

greater than operator (“>”)

less than operator (“

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

What operators can be used to determine greater than or equal to? Less than or equal to?

A

greater than or equal to (“>=”)

less than or equal to operators (“<=”)

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

______ is used to make decisions in code

A

Logic created with conditionals

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

What is the most commonly used conditional?

A

if or if-else

22
Q

How does the if statement work?

A

if some logic (the condition) is true, run a block of code, else run a different block of code

23
Q

The code between the braces - “{” and “}” - is called a _______.

24
Q

_______ are a way of repeating the same block of code over and over.

25
What the two most commonly used types of loops?
1. ) for | 2. ) while
26
How do loops work?
They combine a conditional and a block, running the block over and over until the logic of the conditional is no longer true, or until you force them to stop.
27
A ______ repeats a block of code while a condition is true
while loop
28
_______ combines three semicolon-separated pieces information between the parentheses: initialization, condition and a final expression.
for loop
29
________ are reusable blocks of code that carry out a specific task.
Functions
30
To execute the code in a function you _______.
call it or invoking the function
31
A function can be passed _______ to use
arguments
32
A function may _______ a value to whatever called it.
return
33
How to create a function?
1. ) Use the function keyword 2. ) List arguments in parenthesis 3. ) Create a block of code that creates functionality
34
In a function, the _____ keyword also stops execution of the code in the function; nothing after it will be run.
return
35
``` var add = function (a, b) { return a + b; }; ``` What are a and b?
Parameters
36
JavaScript objects consist of what two parts?
properties and methods
37
An object can be stored in a variable, and the properties and methods accessed using _________.
dot syntax
38
What are object properties?
pieces of data
39
What are JavaScript methods?
Functions that are built into objects
40
``` var jedi = { name: "Yoda", age: 899, talk: function () { alert("another... Sky... walk..."); } }; ``` What are name and age?
Properties -- Essentially variables that are built into objects
41
True or False? Properties can be any kind of data including objects and arrays
True
42
What is a nested object?
An object that is a property of another object
43
True or False? You can create an empty object and then add properties and methods to it.
True
44
________ are lists of any kind of data.
Arrays
45
Each item in the array has an ______ — a number — which can be used to retrieve an element from the array.
An index
46
Array indices start at _____
0
47
The last element of an array has an indices of ______
The length of the array minus 1
48
In JavaScript, you create an array using the _____ syntax:
array-literal syntax Example: var shoppingList = ['Milk', 'Bread', 'Beans'];
49
You retrieve a specific element from an array using _____ syntax
square bracket syntax Example: shoppingList[0]; // retrieve a value Example: shoppingList[1] = 'Cookies'; // set a value
50
What is length? shoppingList.length;
The array length property.
51
You can use _____ and ______ methods to add and remove elements from the end of the array
push and pop Example: shoppingList.push('A new car');