You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ Here you can find course content and homework for the JavaScript 1,2 and 3 modul
9
9
|Week|Topic|Read|Homework|Review|
10
10
|----|-----|----|--------|------|
11
11
|0.|Preparation for your first JavaScript session|[Pre-reading](https://github.com/HackYourFuture/JavaScript/tree/master/Week0) + [CLI Reading Week 1](https://github.com/HackYourFuture/CommandLine/blob/master/Lecture-1.md)|-|
12
-
|1.|• [CLI](https://github.com/HackYourFuture/CommandLine) session with Unmesh :heart: <br>• Intro JavaScript (What is it, where can you use it for)<br>• Variables [var, let, const]<br>• Basic Data types [Strings, Numbers, Arrays]<br>• Operators|[Reading Week 1](https://github.com/HackYourFuture/JavaScript/tree/master/Week1/README.md)|[Homework Week 1](https://github.com/HackYourFuture/JavaScript/tree/master/Week1/MAKEME.md)|[Review](https://github.com/HackYourFuture/JavaScript/blob/master/Week1/REVIEW.md)|
12
+
|1.|• [CLI](https://github.com/HackYourFuture/CommandLine) session with Unmesh :heart: <br>• Intro JavaScript (What is it, where can you use it for)<br>• Variables [var, let, const]<br>• Basic Data types [Strings, Numbers, Arrays, Booleans]<br>• Operators|[Reading Week 1](https://github.com/HackYourFuture/JavaScript/tree/master/Week1/README.md)|[Homework Week 1](https://github.com/HackYourFuture/JavaScript/tree/master/Week1/MAKEME.md)|[Review](https://github.com/HackYourFuture/JavaScript/blob/master/Week1/REVIEW.md)|
Copy file name to clipboardExpand all lines: Week1/MAKEME.md
+91-18Lines changed: 91 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -35,33 +35,106 @@ Write commands to do following:
35
35
36
36
## Step 2: JavaScript
37
37
38
-
> For all the following exercises create a new .js file. Try to find a proper name for each file or make a small comment about what it does inside for future reference
38
+
> For all the following exercises create a new .js file. Try to find a proper name for each file or make a small comment about what it does inside for future reference.
39
39
40
40
1. Declare a variable `x` and initialize it with an integer.
41
-
42
-
2. How do you round the number 7.25, to the nearest integer?
43
-
44
-
3. Create a array called `colors` with the strings red, green and blue inside.
45
-
46
-
4. How can you find the length of the string you just created?
47
-
48
-
5. Write a program that checks the types of two variables and prints out `SAME TYPE` if they are the same type.
49
-
For example:
41
+
1.1 First, _declare_ your variable `x`.
42
+
1.2 Add a console.log statement that explains what _you think_the value of `x` is, like in this example:
43
+
```js
44
+
// TODO -> here you initialize your variable
45
+
console.log('the value of my variable x will be: whateverYouThinkItWillLog')
46
+
```
47
+
1.3 Add a console.log statement that logs the value of `x`
48
+
1.4 Now _initialize_ your variable `x` with an integer
49
+
1.5 Now add a console.log statement that explains what _you think_ the value of `x` is.
50
+
1.6 Add a console.log statement that logs the value of `x`.
51
+
Steps to be taken:
52
+
53
+
```js
54
+
// TODO -> here you declare your variable
55
+
console.log('the value of x will be: whateverYouThinkItWillLog')
56
+
// TODO -> log the actual value of x
57
+
// TODO -> here you initialize your variable
58
+
console.log('the value of x will be: whateverYouThinkItWillLog')
59
+
// TODO -> log value of x again
60
+
```
61
+
62
+
2. Declare a variable `y` and assign a string to it.
63
+
2.1 Write a console.log statement in which explain what you think the value of the string is
64
+
2.2 Now console.log the variable `y`.
65
+
2.3 Now assign a new string to the variable `y`
66
+
2.4 Just like you did before write a console.log statement that explains what you think will be logged to the console.
67
+
2.5 Now console.log `y` again.
68
+
```js
69
+
// TODO -> here you declare AND assign your string
70
+
console.log('the value of my string will be: whateverYouThinkItWillLog')
71
+
// TODO -> log the actual value of the string to the console
72
+
// TODO -> assign a new value to your variable x
73
+
console.log('the value of my string will be: whateverYouThinkItWillLog')
74
+
// TODO -> log the actual value of the string to the console
75
+
```
76
+
77
+
3. How do you round the number 7.25, to the nearest integer?
78
+
3.1 Declare a variable `z` and assign the number 7.25 to it.
79
+
3.2 Console.log `z`.
80
+
3.3 Now round `z` to the nearest integer.
81
+
3.4 Console.log `z` again.
82
+
83
+
4. Arrays!
84
+
4.1 Declare an empty array (you can decide on how to call it yourself).
85
+
4.2 Write a console.log statement in which explain what you think the value of the array is.
86
+
4.3 Console.log your array.
87
+
4.4 Create an array that has your favorite animals inside
88
+
4.5 Log your array
89
+
4.6 Ads Daan's favorite animal (baby pig) to the existing array
90
+
4.7 Log your new array!
91
+
4.8 Now add Gijs's favorite animal to the array (moose), but make sure it will be placed after the first animal that you have placed in your array.
92
+
4.9 Write a console.log statement in which explain what _you think_ the new value of the array is.
93
+
4.10 Log your new new array!
94
+
4.11 Log the length of the array, add a message: "The array has a length of: "(here you should show the length of the array)
95
+
4.12 Eyad does not like giraffes, delete this animal from the array
96
+
4.13 Again log your new array.
97
+
4.14 Now if unlike Gijs, you don't like mooses and you want to delete it from the array, but you don't know the position or the `index` of the item in the array, how can you find it?
98
+
4.15 Log the index of moose to the console. Add a message so it says: "The item you are looking for is at index: " (here you should show the index of the item)
99
+
100
+
5. More strings
101
+
5.1 Let's consider the following string: `let mystring = "this,is,a,test"`.
102
+
5.2 Add the string to your file and console.log it.
103
+
5.3 Find a way to get the length of `mystring`.
104
+
5.4 Console.log the length of `mystring`.
105
+
5.5 The comma's make that the sentence is quite hard to read. Find a way to remove the comma's from the sting and replace them with a spaces
106
+
5.6 Console.log `mystring` to see if you succeeded.
107
+
108
+
109
+
7. Write a program that checks the types of two variables and prints out `SAME TYPE` if they are the same type.
110
+
6.1 First declare at least four variables and assign them with different data types.
111
+
6.2 For each variable write a console log statement that that logs the value
112
+
```js
113
+
let foo =3
114
+
console.log('My the value of my variable foo is: '+ foo)
115
+
```
116
+
6.3 Now write a console.log statement weiring you first explain what you think the _type_ of your variables is.
117
+
6.4 Now use `typeof` to log the actual _type_ of your variables.
118
+
6.5 Now compare the types of your different variables with one another.
119
+
6.6 Make sure to also show a message when the variables you are comparing are not the same type.
120
+
For example:
50
121
```js
51
-
let x = 9;
52
-
let y = 'Hello';
122
+
let x = 9
123
+
let y = 'Hello'
53
124
54
125
if () {
55
-
console.log('SAME TYPE');
126
+
console.log('SAME TYPE')
56
127
}
57
-
128
+
// TODO -> add a way of giving feedback if your variables don't have the same type
58
129
```
59
130
60
-
6. If `x` equals 7, and the only other statement is `x = x % 3`, what would be the new value of `x`?
131
+
8. If `x` equals 7, and the only other statement is `x = x % 3`, what would be the new value of `x`?
132
+
6.1 Add at least 3 `console.log` statements in which you show that you understand what `%` does.
61
133
62
-
7. Write a program to answer the following questions:
63
-
* Can you store multiple types in an array? Numbers and strings?
64
-
* Can you compare inifities? (Not in Eyad's world) - does 6/0 == 10/0? How can you test this?
134
+
9. Write a program to answer the following questions:
135
+
7.1 Can you store multiple types in an array? Numbers and strings?
136
+
7.2 Can you compare inifities? (Not in Eyad's world) - does 6/0 == 10/0? How can you test this?
137
+
7.3 Add console.log statements to the above program's in which you show that you understand the concepts (just like you've done in the above assignments).
0 commit comments