JavaScript Flashcards

1
Q

How do you access the index n of an array?

A

array[n]

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

How do you compare if something is not equal to another?

A

!==

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

How do you add a single line comment?

A

// This would be a single line comment

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

How do you add a multi line comment?

A

/* This is a multi line comment, separated by newlines */

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

What is the command to print to the console for debugging?

A

console.log()

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

What is one syntax for function declaration?

A

var name = function(argument1, argument2) {
code goes here;
more code;
}

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

How would you call a function ?

A

name(argument1, argument2);

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

What is the syntax for an if-else statement?

A
if (condition) {
    code if condition is true;
} else {
    code if condition is false;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the syntax for a for-loop?

A
for ( var i = startValue ; i < endValue ; i+=stepValue ) {
   code to be looped through;
}

Note: Remember the var i here can be anything really, but i is very common for a looping variable.

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