Skip to content

Commit e15b715

Browse files
committed
fixed some number references
1 parent 5e781ae commit e15b715

File tree

1 file changed

+69
-67
lines changed

1 file changed

+69
-67
lines changed

Week2/MAKEME.md

Lines changed: 69 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -48,107 +48,85 @@ In each assignment write at least two `console.log` statements to verify if your
4848
4. Create a function named `vehicleType` that receives a color, and a code, 1 for car, 2 for motorbike. And prints "a blue motorbike" for example when called as `vehicleType("blue", 2)`
4949

5050
5. Can you write the following without the `if` statement, but with just as a single line with `console.log(...);`?
51-
```js
52-
if (3 == 3) {
53-
console.log("true")
54-
} else {
55-
console.log("false")
56-
}
57-
```
51+
52+
```js
53+
if (3 === 3) {
54+
console.log("true")
55+
} else {
56+
console.log("false")
57+
}
58+
```
5859

5960
6. Create a function called `vehicle`, like before, but takes another parameter called age, so that `vehicle("blue", 1, 5)` prints "a blue used car"
6061

6162
7. Make a list of vehicles, you can add `"motorbike"`, `"caravan"`, `"bike"`, or more.
6263

6364
8. How do you get the third element from that list?
6465

65-
9. Change the function `vehicle` to use the list of question 4. So that `vehicle("green", 3, 1)` prints "a green new caravan".
66+
9. Change the function `vehicle` to use the list of question 7. So that `vehicle("green", 3, 1)` prints "a green new caravan".
6667

6768
10. Use the list of vehicles to write an advertisement. So that it prints something like: `"Amazing Joe's Garage, we service cars, motorbikes, caravans and bikes."`. (Hint: use a `for` loop.)
6869

69-
11. What if you add one more vehicle to the list, can you have that added to the advertisement without changing the code for question 7?
70+
11. What if you add one more vehicle to the list, can you have that added to the advertisement without changing the code for question 10?
7071

71-
12. Create an empty object
72+
12. Create an empty object.
7273

7374
13. Create an object that contains the teachers that you have had so far for the different modules.
7475

7576
14. Add a property to the object you just created that contains the languages that they have taught you.
7677

77-
<!-- 13. Create a function that takes two objects as parameters and compares them. You will actually need to write two functions — one that compares with `==` and one that compares with `===`. Remember that objects can have objects inside of them so you'll need to find a way to compare every element of every object (types and values). For example:
78+
15. We saw that we can pass functions as arguments to other functions. Your task is to write a function that takes another function as an argument and runs it.
7879

79-
```js
80-
let obj1 = {
81-
a: 1,
82-
b: 'this is the letter b',
83-
c: { foo: 'what is a foo anyway',
84-
bar: [1,2,3,4]
80+
```js
81+
function foo(func) {
82+
// What to do here?
8583
}
86-
}
87-
88-
let obj2 = {
89-
a: '1',
90-
b: 'this is the letter b',
91-
c: { foo: 'what is a foo anyway',
92-
bar: [1,2,3,4]
84+
85+
function bar() {
86+
console.log('Hello, I am bar!');
9387
}
94-
}
95-
```
96-
97-
In our example we'll say that `obj1 == obj2` is `true` and `obj1 === obj2` is `false`. Make sure you can see why before you write any code!
98-
99-
Note: give this exercise your best shot but don’t spend more than, say, one hour on it.
100-
-->
101-
15. We saw that we can pass functions as arguments to other functions. Your task is to write a function that takes another function as an argument and runs it.
102-
103-
```js
104-
function foo(func) {
105-
// What to do here?
106-
}
107-
108-
function bar() {
109-
console.log('Hello, I am bar!');
110-
}
111-
112-
foo(bar);
113-
```
88+
89+
foo(bar);
90+
```
11491

11592

11693
16. Write some code to test two arrays for equality using `==` and `===`. Test the following:
11794

118-
```js
119-
let x = [1,2,3];
120-
let y = [1,2,3];
121-
let z = y;
122-
```
95+
```js
96+
let x = [1,2,3];
97+
let y = [1,2,3];
98+
let z = y;
99+
```
123100

124-
What do you think will happen with `x == y`, `x === y` and `z == y` and `z == x`? Prove it!
125-
126-
> Don't cheat! Seriously - try it first.
127-
101+
What do you think will happen with `x == y`, `x === y` and `z == y` and `z == x`? Prove it!
102+
103+
> Don't cheat! Seriously - try it first.
104+
128105
129-
Check out this [Fiddle](http://jsfiddle.net/jimschubert/85M4z/). You need to open your browser’s Developer Tools to see the console output. Press the Run button in the upper right corner to run the code.
106+
Check out this [Fiddle](http://jsfiddle.net/jimschubert/85M4z/). You need to open your browser’s Developer Tools to see the console output. Press the Run button in the upper right corner to run the code.
130107
131-
More insights from this [Stack Overflow question](http://stackoverflow.com/questions/22395357/how-to-compare-two-arrays-are-equal-using-javascript).
108+
More insights from this [Stack Overflow question](http://stackoverflow.com/questions/22395357/how-to-compare-two-arrays-are-equal-using-javascript).
132109
133110
134111
17. Take a look at the following code:
135112
136-
```js
137-
let o1 = { foo: 'bar' };
138-
let o2 = { foo: 'bar' };
139-
let o3 = o2;
113+
```js
114+
let o1 = { foo: 'bar' };
115+
let o2 = { foo: 'bar' };
116+
let o3 = o2;
140117
141-
```
118+
```
142119
143-
Show that changing `o2` changes `o3` (or not) and changing ~~`o2` changes `o3`~~ `o1` changes `o3`(or not).
144-
145-
Does the order that you assign (`o3 = o2` or `o2 = o3`) matter? {Jim Cramer: ???}
120+
Show that changing `o2` changes `o3` (or not) and changing `o1` changes `o3`(or not).
121+
122+
Does the order that you assign (`o3 = o2` or `o2 = o3`) matter?
146123
147124
18. What does the following code return? (And why?)
148-
```js
149-
let bar = 42;
150-
typeof typeof bar;
151-
```
125+
126+
```js
127+
let bar = 42;
128+
typeof typeof bar;
129+
```
152130
153131
154132
> ‘Coerce' means to try to change - so coercing `var x = '6'` to number means trying to change the type to number temporarily.
@@ -176,3 +154,27 @@ How to hand in your homework:
176154
177155
:star: Additional resources and review: [here](https://github.com/HackYourFuture/JavaScript/tree/master/Week2/REVIEW.md) (work in progress):star:
178156
157+
<!-- 13. Create a function that takes two objects as parameters and compares them. You will actually need to write two functions — one that compares with `==` and one that compares with `===`. Remember that objects can have objects inside of them so you'll need to find a way to compare every element of every object (types and values). For example:
158+
159+
```js
160+
let obj1 = {
161+
a: 1,
162+
b: 'this is the letter b',
163+
c: { foo: 'what is a foo anyway',
164+
bar: [1,2,3,4]
165+
}
166+
}
167+
168+
let obj2 = {
169+
a: '1',
170+
b: 'this is the letter b',
171+
c: { foo: 'what is a foo anyway',
172+
bar: [1,2,3,4]
173+
}
174+
}
175+
```
176+
177+
In our example we'll say that `obj1 == obj2` is `true` and `obj1 === obj2` is `false`. Make sure you can see why before you write any code!
178+
179+
Note: give this exercise your best shot but don’t spend more than, say, one hour on it.
180+
-->

0 commit comments

Comments
 (0)