Declaring a Variable Flashcards

(31 cards)

1
Q

What is Syntax?

A

Syntax is the name given to rules that determine how a code should be written.

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

What is a Variable Declaration?

A

A Variable Declaration is the creation of a label in order to name data.

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

What is Initialization?

A

Initialization is the process of giving a value, or data, to the label (variable declaration)

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

What is the most common way to create a variable in JavaScript?

A

The most common way to create a variable in javascript is to declare it with a name and to then initialise it with a value in one line.

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

What is const?

A

const is a keyword used for beginning a declaration.

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

Where is the string value in the code const greeting = ‘hello there!’

A

The string value is ‘hello there!’

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

Which part of const greeting = ‘hello there!’ reflects the process of initialisation?

A

‘hello there!’ reflects the process of initialisation.

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

Which part of const greeting = ‘hello there!’ is known as the Variable?

A

greeting is known as the variable

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

Which part of const greeting = ‘hello there!’ reflects the process of declaration?

A

const reflects the process of declaration

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

What is another way of saying “initalise the value”

A

“assign the value” is another way of saying “initalise the value”

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

Which symbol is the assignment operator?

A

The “=” symbol is the assignment operator.

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

Which character in const greeting = ‘hello there!’ is the assignment operator?

A

The “=” is the assignment operator.

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

What are Keywords/Reserved Words in JavaScript?

A

Keywords/Reserved Words refer to certain words in Javascript that have a special meaning and therefore can’t be used as names for variables.

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

What is an example of a Reserved Word in JavaScript?

A

const

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

What is a Variable?

A

A named storage location for the storing of data.

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

What else can the assignment symbol be used for other than to initialise a variable?

A

The assignment symbol can also be used for Reassigning a new value / new values to a variable.

17
Q

In the code - let greeting =’hello’; greeting=’hola’; - which greeting will be displayed on the website?

A

‘hola’ will be the greeting displayed on the website because ‘hello’ has been reassigned ‘hola’

18
Q

Which keyword allows the value of a variable to be reassigned?

A

The keyword ‘let’ allows the values of a variable to be reassigned.

19
Q

Does const allow you to reassign the values of a variable?

A

No, const does not allow you to reassign values to the variable.

20
Q

What does const tell the program?

A

const tells the program that the values of the variable are not allowed to be changed.

21
Q

Why will ‘salut’ not be shown as a greeting in the code - const greeting = ‘hola’; greeting=’salut’;

A

‘Salut’ will not be shown on the website because the greeting=’salut’; code will not run as a result of the keyword being used to declare the variable being ‘const’ instead of ‘let.’

22
Q

What is the ‘var’ keyword in JavaScript?

A

The ‘var’ keyword in JavaScript is an older version of the ‘const’ and ‘let’ syntax.

23
Q

What is a Convention?

A

Convention is a commonly-agreed upon way of writing code that helps maintain consistency and readability among developers.

24
Q

What is the Convention in JavaScript when naming variables?

A

The convention in javascript when naming variables is to use camelCase.

25
What is camelCase in Javascript?
camelCase is the convention in javascript when naming variables. camelCase means that the first word is in lowercase and the following words are all in UpperCase.
26
What three things define a good variable name?
A good variable name makes clear what data type is being held. A good variable name conveys the purpose of the value being held. A good variable name is descriptive without being too long or difficult to read.
27
Which Variable is better? - const isPublished - or - const Published - ?
- const isPublished - is the better variable because it makes clear what data type is being held.
28
Which Variable is better? - const h - or - const articleHeading - ?
- const articleHeading - is the better variable.
29
Why is 'h' a bad name for a Variable?
It prevents other people from being able to understand your code.
30
Why are Semi Colons used for by Programmers?
Programmers use the semi colon ; symbol to break up instructions within a code.
31
Why are Semi Colons largely optional in JavaScript?
Semi Colons are largely optional in JavaScript because JavaScript will inset the semi colons itself when executing the code.