Skip to content
Snippets Groups Projects
Commit e8a08db2 authored by Andrej Rasevic's avatar Andrej Rasevic
Browse files

adding Midterm materials

parent 5b5f21f1
No related branches found
No related tags found
No related merge requests found
### Midterm CMSC389N Summer 2020
The exam is worth 100 points
Exam Duration 90 minutes
To complete the exam you must complete the questions in `Questions.md` as well as complete the code for `deepEqual.js` and `events.html`. `Questions.md` is worth 40 points, `deepEqual.js` is worth 25 points and `events.html` is worth 35 points.
1. `Questions.md` (40 points)
To complete `Questions.md`, just type your answers after each question.
2. `deepEquals.js` (25 points)
During lecture we covered an example of a custom equal function that assumed that the properties of each key of an object were not nested objects (i.e. the nesting of objects was at most 1 level deep).For `deepEqual.js` you must complete the function inside so that it compares any 2 javscript objects and returns true if and only if every value of every proprty of both objects is identical.
Your implementation can include at most 1 helper funtion that should test if the parameter passed to the function is an objecty or not. You may find the `typeof` operator helpful. Also each of the parameters passed to the `deepEquals` function must be objects, i.e. they cannot be primitives, arrays, functions, etc.
3. `events.html` (35 points)
We have provided you all the necessary html to complete this part of the exam and an empty script tag. You need to use the html elements we have provided you, __AS WRITTEN__, and add event listeners/handlers so that you get the following output:
1. Stop Event Propogation box is un-checked
If the user clicks the `Outer Div` section then the console should print out in __EXACTLY__ this order:
Outer Div clicked first
Outer Div clicked
If the user clicks the `Inner Div` section then the console should print out in __EXACTLY__ this order:
Outer Div clicked first
Inner Div clicked
Outer Div clicked
If the user clicks anywhere outside of the blue div areas no output should appear.
2. Stop Event Propogation box is checked
If the user clicks the `Outer Div` section then the console should print out in __EXACTLY__ this order:
Outer Div clicked
If the user clicks the `Inner Div` section then the console should print out in __EXACTLY__ this order:
Inner Div clicked
If the user clicks anywhere outside of the blue div areas no output should appear.
To complete this part of the exam you will need to use the `event.stopPropogation()` function . When you invoke this function inside of an event handler it stops the propogation or capturing of the event at the currentTarget. You also may find helpful the `checked` property of an html checkbox element to determine whether or not it is checked. It is a boolean value and will return true or false. You may load the file in your browser to see what the page looks like. You do not need to use `npx http-server` to dos so - you can use the file protocal by just passing the absolute path of the file on your local system inside of your browsers's navigation bar.
Good luck!
\ No newline at end of file
## Javascript/HTML/CSS Short Answer Questions 40 points
### Complete the questions below
1. What are the differences between declaring a variable in javascript with `var`, `let` or `const`?
2. What is hoisting? Give an example of code where a function definition can be hoisted and where it cannot be.
3. What is the difference between `call`, `apply` and `bind`?
4. For this problem assume your code is running in the browser. Given the following script:
```
let goat1 = {
firstName: 'Novak',
lastNmae: 'Djokovic'
}
let goat2 = {
firstName: 'Novak',
lastNmae: 'Djokovic'
}
console.log(goat1 == goat2)
console.log(goat1 === goat2)
console.log(goat1['firstName'] === goat2['firstName'])
```
What is the output of this script?
5. How would you make an object immutable in javascript? Give a code example where you create an object that is immutable.
6. What are computed properties?
7. What is the difference between a class and an id attribute in css?
8. Describe the difference between a child and descendent selector in css?
9. What is the difference between `undefined` and `null` in `javascript`?
10. How does the `new` keyword work with a constructor function in `javascript`?
11. What is event bubbling? How is it different from capturing?
12. What is the difference between `event.target` and `event.currentTarget` properties?
13. What are the ways javascript can be included in an html file?
14. What is the output of the following code:
```
console.log(y);
y = 1;
-------------------
console.log(y);
var y = 2;
-------------------
y = 3;
console.log(y);
var y;
```
15. Define higher order functions. Give 3 examples of higher order functions we have encoutered in javascript
16. Create a function named `printDate` 3 different ways (not including a function constructor). It should take 3 parameters: month (name of the month), number (value corresponding to the number day in a given month), and year. It should return a string representation of the passed date in the following format:
`"The date entered is: <month> <day>, <year>"`
You must use the template literal syntax to provide your return value.
// complete the function below
function deepEquals(obj1, obj2) {
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<body>
<style>
div {
padding: 50px;
background-color: rgba(0,0,255,0.3);
text-align: center;
cursor: pointer;
}
</style>
<h1>Event Handling in the DOM</h1>
<div id="outer"> Outer Div
<div id="inner">Inner Div</div>
</div>
Stop Event Propogation
<input type="checkbox" id="check">
<script>
// Place your code here
</script>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment