JavaScript Flashcards

(54 cards)

1
Q

Minimal Viable Product (MVP)

A

the simplest version of an app that a developer can share with users to receive feedback

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

how do you link a JS file?

A

within the script tag

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

where do you place the script tag?

A

at the very bottom of the html file, before the closing

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

why is the JS linked at the bottom of the page?

A

when the browser sees a tag, it will immediately run the JS file preventing from moving onto the next html tag

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

what is window.alert (“ “)?

A

alert window popup

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

what is a function?

A

predefined action that we can call or invoke in our code (after we declare it earlier in the code)

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

what does “passing an argument” mean?

A

placing content between the parentheses in a function

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

what is an expression?

A

each piece of code, separated by semicolons

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

how do you declare a function?

A

use the keyword function, followed by the name we want to give it

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

what is the code between curly braces ({ }) called?

A

code block

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

what does it mean to “call a function”?

A

telling the computer to run or execute that set of actions

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

what do you need to do to allow a function to work?

A

call the function

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

what is this an example of?

function fight ( ) {
window.alert (" ");
}

fight ( );

A

calling a function

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

what is user input?

A

info that a user enters into a program

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

what does this function do?

window.prompt (“ “)

A

a window pops up with an area for the user to input data

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

what is a variable?

A

named location for a value that gets stored in the browser’s memory when a program is run

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

how does the browser capture the data entered into a prompt by a user?

A

adding variables

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

what is this an example of?

var playerName = window.prompt (“ “)

A

a variable. we give the data a variable name (playerName) allowing us to refer to it consistently by just calling on that name

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

var keyword

A

whenever this keyword is used it tells the program that we are creating a new variable and the next word is going to be the name of the variable

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

what is a variable name?

A

the actual name that will store the info assigned to the variable - the browser will store this name to recall later in the program

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

what is camel casing?

A

only use with two worded names - the first word is lower case with the first letter in the second word being capitalized

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

what is an assignment operator?

A

(=) used to set the value to a variable name

23
Q

what is a string data type?

A

sting of text - must be wrapped in “ “

24
Q

what is number data?

A

a whole number or decimal

25
what is boolean data?
only given a value of true or false
26
how do you create a comment in JS?
/* */
27
what is the console.log?
a method for develops to write code inconspicuously to let developers know what the code is doing
28
what is a screen concantenation?
string data that needs to include variable data
29
what is this an example of? console.log ("Tony" + "is ready.");
a screen concantenation
30
when we concantenate strings we need to include a leading or trailing ___ so the variable doesn't run up against the word before or after it
spaces
31
what are the two ways to create a function?
``` function declaration: create a function using the function keyword first ex. function fight () { } ``` ``` function expression: create a function by assigning it to a variable ex. var fight = function () { } ```
32
what happens when you list a variable name on the left side of the assignment operator?
stores data to that variable
33
what happens when you list a variable name on the right side of the assignment operator?
we will use the actual value that variable holds at that moment
34
what does "state" mean?
refers to the data in our application at a specific point in time- conveys what is happening now and helps decide what happens next
35
what are conditions?
checks performed on the status of our code and helps the program determine what to do
36
what is this an example of? if (playerHealth > 0) { console.log ("Your player is still alive!"); }
a condition
37
why do we use the "if" keyword in a condition?
its telling the browser that we're going to check for a condition to be true or false and execute a block of code based on the result
38
what is this an example of? ``` if (playerHealth === 0) { console.log("this will not run"); } else { console.log ("this will run instead"); } ```
a control flow statement
39
what are three equal signs used to do? | ===
allows you to check if two values are directly equal to one another
40
what is pseudocode?
plain-language description of the steps that an application must complete
41
what is an array?
a data structure designed to store data as a list (ex. var enemyNames = ([tony, roborto, james]);
42
what is primitive data?
data that only holds one value, such as a string, integer, or boolean
43
what is object data?
datatype that can store more than one value of data
44
why are for loops used?
used whenever you need the same operation done repetitively
45
what is this an example of? ``` for (var i = 0; i < 3; i++) { console.log("apple"); } ```
a for loop
46
what is the control flow?
the order in which the computer executes statements in a JS file
47
the ____ is the statement executed, initializing the loop iterator or counter
``` initial expression ex. var i = 0; ```
48
the ___ statement is evaluated after the initial expression, if the condition evaluates to be true, the loop executes - if the value is false, the loop terminates
condition | ex. i < 3;
49
the ____ executes, incrementing the iterator, which is the variable i
increment expression | ex. i++
50
what is the while loop?
type of control flow statement that loops or repeatedly executes a statement while a condition remains true
51
variables that are declared outside of any functions are considered ____
global
52
____ scope can only be accessed within the scope of a function
local scope
53
if a global variable and local variable have the same name, the ____ variable will take precedence
local
54
when do you use switch statements?
when checking a single value against multiple possibilities or cases