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 _______.

A

A block

24
Q

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

A

Loops

25
Q

What the two most commonly used types of loops?

A
  1. ) for

2. ) while

26
Q

How do loops work?

A

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
Q

A ______ repeats a block of code while a condition is true

A

while loop

28
Q

_______ combines three semicolon-separated pieces information between the parentheses: initialization, condition and a final expression.

A

for loop

29
Q

________ are reusable blocks of code that carry out a specific task.

A

Functions

30
Q

To execute the code in a function you _______.

A

call it or invoking the function

31
Q

A function can be passed _______ to use

A

arguments

32
Q

A function may _______ a value to whatever called it.

A

return

33
Q

How to create a function?

A
  1. ) Use the function keyword
  2. ) List arguments in parenthesis
  3. ) Create a block of code that creates functionality
34
Q

In a function, the _____ keyword also stops execution of the code in the function; nothing after it will be run.

A

return

35
Q
var add = function (a, b) {
    return a + b;
};

What are a and b?

A

Parameters

36
Q

JavaScript objects consist of what two parts?

A

properties and methods

37
Q

An object can be stored in a variable, and the properties and methods accessed using _________.

A

dot syntax

38
Q

What are object properties?

A

pieces of data

39
Q

What are JavaScript methods?

A

Functions that are built into objects

40
Q
var jedi = {
    name: "Yoda",
    age: 899,
    talk: function () { alert("another... Sky... walk..."); }
};

What are name and age?

A

Properties – Essentially variables that are built into objects

41
Q

True or False? Properties can be any kind of data including objects and arrays

A

True

42
Q

What is a nested object?

A

An object that is a property of another object

43
Q

True or False? You can create an empty object and then add properties and methods to it.

A

True

44
Q

________ are lists of any kind of data.

A

Arrays

45
Q

Each item in the array has an ______ — a number — which can be used to retrieve an element from the array.

A

An index

46
Q

Array indices start at _____

A

0

47
Q

The last element of an array has an indices of ______

A

The length of the array minus 1

48
Q

In JavaScript, you create an array using the _____ syntax:

A

array-literal syntax

Example: var shoppingList = [‘Milk’, ‘Bread’, ‘Beans’];

49
Q

You retrieve a specific element from an array using _____ syntax

A

square bracket syntax

Example: shoppingList[0]; // retrieve a value
Example: shoppingList[1] = ‘Cookies’; // set a value

50
Q

What is length?

shoppingList.length;

A

The array length property.

51
Q

You can use _____ and ______ methods to add and remove elements from the end of the array

A

push and pop

Example: shoppingList.push(‘A new car’);