Midterm Practice Flashcards

1
Q

How do we select the id attribute in css?

A

“#id”

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

How do we select the class attribute in css?

A

.class

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

What does “p” select in css?

A

Selects all the paragraphs

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

What does “p” select in css?

A

Selects all the paragraphs

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

What does “div p” select is css?

A

Selects all paragraphs inside div elements

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

What does “div, p” select in css?

A

Selects all the div and p tags

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

What does “div+p” select in css?

A

Selects all the sibling p tags that immediately follow a div tag
“<div></div>”
“<p></p> <– this one–>”
“<p></p> <– this does not follow a div –>”

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

What does :hover do in css?

A

Applies a style to an element when the mouse is over it

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

Code test:
<?php
$pass = “test”;
$hash1 = password_hash($pass, PASSWORD_BCRYPT);
$hash2 = password_hash($pass, PASSWORD_BCRYPT);
if($hash1 == $hash2){
echo “matches”;
}
else{
echo “doesn’t match”;
}

?>

A

doesn’t match (random salt is assigned during hash to prevent two or more users from having the same password key)

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

What does == do?

A

Value equality matches but not type

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

What does === do?

A

Value AND type equality

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

What does $x++ do?

A

Increments x by 1

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

What does $x– do?

A

Decrements x by 1

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

What does && do?

A

Logical AND (both conditions must be true)

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

“What does || do?”

A

Logical OR (either condition must be true)

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

What does ! typically do in !$x?

A

Negates it (flips the boolean or truthy value)

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

What does % do in $x % $y?

A

Remainder/Modulus/Modulo

17
Q

What does . do in php?

A

Concats data/variables

18
Q

What does + do in php?

A

Addition Arithmetic

19
Q

In SQL how do you do a partial match on a column?

A

LIKE and the % wildcard

20
Q

So LIKE “hi%” partial matches what?

A

Any data in the column starting with hi

21
Q

So LIKE “%hi%” partial matches what?

A

Any data in the column that contains hi

22
Q

So LIKE “%hi” partial matches what?

A

Any data in the column ending in hi

23
Q

In SQL how do you select unique data?

A

SELECT DISTINCT

24
Q

In JS what does console.log() do?

A

Prints to the developer console

25
Q

In JS what does confirm() do?

A

Built in dialog providing a positive and negative action

26
Q

In JS what does prompt() do?

A

Built in dialog asking for user input

27
Q

while:

A

keeps running as long as the condition is true

28
Q

do while:

A

runs at least once and continues as long as true

29
Q

foreach:

A

loops over each item in a collection

30
Q

for:

A

loops a specific number of times

31
Q

Find Elements


let ele = document.getElementById("hi");
console.log(ele); // what's the value

<body>
<div>Hello</div>

</body>

A

Null; runs before page is ready

32
Q

Form Submit
<!-- the url contains ?name=Joe&age=50 -->

<form>
<input></input>
<input></input>
</form>

<?php //assuming the form was just submitted
var_dump($_REQUEST);
//what is the output of $_REQUEST?
?>

A

[ “job”:”Painter”, “age”:51, “name”: “Joe” ]

33
Q

Logic Check 1
<?php
$x = 0;
for($i = 0; $i < 3000; $i++){
$x++;
if($x % 2 == 0){
$x–;
}

}
echo “x is $x”;
?>

A

x is 1

34
Q

Logic Check 2
<?php
$x = 0;
for($i = 0; $i < 3000; $i++){
$x++;
if($i % 2 == 0){
$x–;
}

}
echo “x is $x”;
?>

A

x is 1500

35
Q

Logic Check 3
<?php
$x = 0;
for($i = 0; $i < 3000; $i++){
$x++;
if($x > 2){
$x–;
}

}
echo “x is $x”;
?>

A

x is 2

36
Q

Logic Check 4
<?php
$x = 0;
for($i = 0; $i < 3000; $i++){

if($x % 2 == 0){
	$x--;
}
if($i % 2 == 0){
	continue;
}
$x++; } echo "x is $x"; ?>
A

x is 0

37
Q

Defined Variables
<?php
while($x++ < 10){
echo “$x <br></br>”;
}
//does x need to be defined?
?>

A

no, it’s a warning for now. PHP will do it’s best to assume the initial value. Since it’s addition it can assume you want it to be an int so it uses the default value of 0 then applies the arithmetic.

38
Q

Random onload sample


window.addEventListener("load", () => {
let eles = document.getElementsByTagName("div");
console.log(eles);
for (let i = 0; i < eles.length; i++) {
let t = eles[i].innerText;
let otherIndex = parseInt(Math.random() * eles.length);
eles[i].innerText = eles[otherIndex].innerText;
eles[otherIndex].innerText = t;
}
});

<body>
<div>Hello</div>
<div>Bye</div>
<div>What?</div>
<div>Who?</div>
<div>Where?</div>
</body>

A
39
Q

Update an immediate sibling
<input></input>
<span>This will change</span>

A