Algorithm Challenges Book Flashcards

1
Q

What is the purpose of coding a FUNCTION?

A

For code that you expect to use often, whether called by various places in your own code, or perhaps even caled by others’ code, you can separate this out and give it a specific label

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

What are the six (primitive) data types in javascript?

A

Number, String, Boolean, Undefined, Null, Symbol (new in ECMAScript 6)

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

What is unique about number in Javascript?

A

Makes no distinction between integers and floating-point numbers

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

Describe the difference between x = y and x == y

A

x = y, set the value of x to become the value of y
x ==y, is the value of x equivalent to the value of y?

Assign y to x
Are x and y equal?

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

How is javascript type? (loose? strict?)

A

It is loosely typed: it very willingly changes a variable’s data type, whenever needed.

The == operator ACTUALLY means ‘after converting x and y to the same data type, are their values equivalent?’

If you want strict comparison without converting data types, then you will use the === operator

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

What is the developer console?

A

The developer console is where errors, warnings and other messages about our program go.

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

The console.log function always takes what type of data type?

A

The console.log function will always take in a string. If we send it something that isn’t a string, JS will first convert it to a string that it can print.

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

Calling the function is also referred to as

A

Running or executing the function.

In Review: when we DECLARE a function, it allows some other caller to execute our function from some other place in the code, at some other time.

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

What are the complex conditional values? (and, or, not)

A

And is &&
Or is ||
Not is !

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

What is the difference between a for and while loop?

A

For loops are useful when you know how many times tnhose lines of code will run. While loops are slightly better when you don’t know how many times to loop, but you will loop WHILE a certain test continues to be true.

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

How do you create a for loop?

A

You specify three things within parentheses following the for: any initial setup, a test that must be true in order to start the loop, and any code to be run at tend of each time through the loop.

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

What are other ways of writing num = num + 1?

A

num = num +1, can be equally written as:

num +=1
num++
++num

Note: You could also decrement by num–; or –num; there are also *= and /=

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

Describe BREAK and CONTINUE

A

With more complex code, you might need to break out of the loop early, or to skip the current pass but continue looping.

Break immediately exits the specific loop you are currently in and continues immediately following the loop.

Continue skips the rest of the current pass through the loop, but any loop=end statement is executed and looping will continue.

With both, once they run, any subsequent code within the loop is skipped.

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

What is a parameter?

A

In ordert to increase functionality and flexibility of a function, you use parameters.

The function caller simply inserts these values (called arguments) between parentheses, when it executes the function.

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

What is a return value?

A

Parameters give functions a lot more flexibility. However, sometimes you don’t want a function to do all the work; maybe you just want it to give you information so that then your code can do something based on the answer it gives you. This is when you would use the return value for a function!rt

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