Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d4bd775

Browse files
committed
homework update week1
1 parent d17a03c commit d4bd775

File tree

2 files changed

+82
-35
lines changed

2 files changed

+82
-35
lines changed

Week1/MAKEME.md

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,77 @@
1-
## Assignments week 1:
1+
## Homework week 1:
2+
3+
>[Here](https://github.com/HackYourFuture/JavaScript/tree/master/Week1/README.md) you find the readings you have to complete before the second lecture.
24
35
We covered a bit of command line usage in the first class and got a program running which is great. If you need a refresher for the command line please have a look here: https://github.com/HackYourFuture/CommandLine
46

5-
### Homework
7+
## Before you start with the homework:
68

7-
1. Create a `.js` file that prints `Hello` when you run it from the command line. (Hint: `node` is the program that can run your JavaScript files.)
9+
1. Watch: [What is programming] (https://www.khanacademy.org/computing/computer-programming/programming/intro-to-programming/v/programming-intro) Just watch the 2 min video, you do not have to do the entire JavaScript course (It could be useful later on though).
10+
2. Please watch the following parts of the course, [Programming Foundations Fundamentals](https://www.lynda.com/Programming-Foundations-tutorials/Welcome/83603/90426-4.html) on Lynda.com (if you don't have access to Lynda yet ask Gijs):
11+
0. Introduction
12+
1. Programming Basics
13+
2. Core Programming Syntax
14+
3. Variables and Data Types
815

9-
2. Write a program (like we did in class) that checks the types of two varibales and prints out `SAME TYPE` if they are the same type.
10-
For example:
11-
```js
12-
let x = 9;
13-
let y = 'Hello';
16+
## Step 1: Command Line
1417

15-
if () {
16-
console.log('SAME TYPE');
17-
}
18+
1. Create a `.js` file that prints `Hello` when you run it from the command line. (Hint: `node` is the program that can run your JavaScript files.)
1819

19-
```
20+
>2. Write commands to do following:
21+
1. create a directory. Enter a directory. Create an empty file named blank.
22+
2. Then write the content `"Hello"` five times to the file greetings.txt.
23+
Then copy the file greetings.txt and paste its contents into 1.txt, 2.txt, 3.txt, 4.txt and 5.txt.
24+
3. Then write the text "cat" to pets.txt
25+
Then append the text "dog" to pets.txt
26+
Then append the text "hamster" to pets.txt
27+
4. Then write the text "cat" to commands.txt
28+
Then append the text "ls" to commands.txt
29+
Then append the text "pwd" to commands.txt
30+
5. Then find unique strings from these two files pets.txt and commands.txt
31+
and store the unique strings in lovelyCommands.txt
2032

21-
3. Create a function that takes 3 arguments and returns the sum of the three arguments.
2233

23-
4. Create a function named `colorCar` that receives a color, and prints out, "a red car" for example. (Hint: put it in your file and run it like before.)
34+
## Step 2: JavaScript
2435

25-
5. Create an object and a function that takes the object as a parameter and prints out all of its names and values.
36+
> 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
2637
27-
6. 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)`
38+
1. Declare a variable `x` and initialize it with an integer.
2839

29-
7. Create a function called `vehicle`, like before, but takes another parameter called age, so that `vehicle("blue", 1, 5)` prints "a blue used car"
40+
2. How do you round the number 7.25, to the nearest integer?
3041

31-
8. Make a list of vehicles, you can add `"motorbike"`, `"caravan"`, `"bike"`, or more.
42+
3. Create a array called `colors` with the strings red, green and blue inside.
3243

33-
9. How do you get the third element from that list?
44+
4. How can you find the length of the string you just created?
3445

35-
10. Change the function `vehicle` to use the list of question 5. So that `vehicle("green", 3, 1)` prints "a green new caravan".
46+
5. Write a program that checks the types of two variables and prints out `SAME TYPE` if they are the same type.
47+
For example:
48+
```js
49+
let x = 9;
50+
let y = 'Hello';
3651

37-
11. Use the list of vehicles to write an advertisment. So that it prints something like: `"Amazing Joe's Garage, we service cars, motorbikes, caravans and bikes."`. (Hint: use a `for` loop.)
52+
if () {
53+
console.log('SAME TYPE');
54+
}
3855

39-
12. What if you add one more vehicle to the list, can you have that added to the advertisement without changing the code for question 8?
56+
```
57+
58+
6. If `x` equals 7, and the only other statement is `x = x % 3`, what would be the new value of `x`?
4059

41-
13. Write a program to answer the following questions:
60+
7. Write a program to answer the following questions:
4261
* Can you store multiple types in an array? Numbers and strings?
4362
* Can you compare inifities? (Not in Eyad's world) - does 6/0 == 10/0? How can you test this?
4463

45-
14. Can you write the following without the `if` statement, but with just as a single line with `console.log(...);`?
46-
```js
47-
if (3 == 3) {
48-
console.log("true")
49-
} else {
50-
console.log("false")
51-
}
52-
```
53-
64+
### Step 3: **Some freeCodeCamp challenges (10 hours):**
5465

55-
On freecodecamp.com please try to do all [Basic JavaScript](https://www.freecodecamp.com/challenges/learn-how-free-code-camp-works) exercises (there are some topics we did not cover but you can do it). Please make sure you REALLY understand the exercises below:
66+
On freeCodeCamp.com please do all [Basic JavaScript](https://www.freecodecamp.com/challenges/learn-how-free-code-camp-works) exercises (there are some topics we did not cover but you can do it). Please make sure you REALLY understand the exercises below:
5667

5768
- https://www.freecodecamp.com/challenges/multiply-two-decimals-with-javascript
5869
- https://www.freecodecamp.com/challenges/store-multiple-values-in-one-variable-using-javascript-arrays
5970
- https://www.freecodecamp.com/challenges/build-javascript-objects
6071
- https://www.freecodecamp.com/challenges/add-new-properties-to-a-javascript-object
6172
- https://www.freecodecamp.com/challenges/delete-properties-from-a-javascript-object
6273

74+
> Hint, if you solve the FreeCodeCamp challenges and they are new concepts to you and you would like to take a look at them later on in the program, Copy your answers from FCC in a .js file and upload them to Github for future reference. In this way you build your own little documentation, if you look back at them first try to understand what it does before you run them.
75+
76+
Additional resources and review: [here](https://github.com/HackYourFuture/JavaScript/tree/master/Week1/REVIEW.md) (work in progress)
77+

Week2/MAKEME.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
11
## Homework Week 2
22

3-
1. 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:
3+
### Step 1: JavaScript
4+
> 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
5+
6+
1. Create a function that takes 3 arguments and returns the sum of the three arguments.
7+
8+
2. Create a function named `colorCar` that receives a color, and prints out, "a red car" for example. (Hint: put it in your file and run it like before.)
9+
10+
3. Create an object and a function that takes the object as a parameter and prints out all of its names and values.
11+
12+
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)`
13+
14+
5. Can you write the following without the `if` statement, but with just as a single line with `console.log(...);`?
15+
```js
16+
if (3 == 3) {
17+
console.log("true")
18+
} else {
19+
console.log("false")
20+
}
21+
```
22+
23+
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"
24+
25+
7. Make a list of vehicles, you can add `"motorbike"`, `"caravan"`, `"bike"`, or more.
26+
27+
8. How do you get the third element from that list?
28+
29+
9. Change the function `vehicle` to use the list of question 5. So that `vehicle("green", 3, 1)` prints "a green new caravan".
30+
31+
10. Use the list of vehicles to write an advertisment. So that it prints something like: `"Amazing Joe's Garage, we service cars, motorbikes, caravans and bikes."`. (Hint: use a `for` loop.)
32+
33+
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 8?
34+
35+
12. 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:
436

537
```js
638
var obj1 = {
@@ -54,7 +86,7 @@
5486

5587
More insights from this [Stack Overflow question](http://stackoverflow.com/questions/22395357/how-to-compare-two-arrays-are-equal-using-javascript).
5688

57-
**Some freeCodeCamp challenges:**
89+
### Step 2: **Some freeCodeCamp challenges:**
5890

5991
3. [Comparisons with the Logical And Operator](https://www.freecodecamp.com/challenges/comparisons-with-the-logical-and-operator)
6092

0 commit comments

Comments
 (0)