diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..6f3a2913 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/JavaScript1/Week1/homework.md b/JavaScript1/Week1/homework.md deleted file mode 100644 index e7ea14b6..00000000 --- a/JavaScript1/Week1/homework.md +++ /dev/null @@ -1,132 +0,0 @@ -# Homework week 1 - -![Hacking](https://media.giphy.com/media/eCqFYAVjjDksg/giphy.gif) -## Step 1: Before you start with the homework: -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). - -## Step 2: Javascript warm up part one -Lets get started with some warm up exercises: On freeCodeCamp.com please do the [Basic JavaScript](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript) exercises up and until the **"Shopping List"** exercise (there are some topics we did not cover but you can do it). - -Please add your freecodecamp username as answer for this exercise! - -## Step 3: Javascript warm up part two -1. Write a `console.log` statement saying "Hello World!" for each language that you know. - -For example: -``` -Halo, dunia! // Indonesian -Ciao, mondo! // Italian -Hola, mundo! // Spanish -``` - -2. Create a variable that rounds the number 7.25, to the nearest integer (i.e., whole number) - -3. Working with arrays -* Declare an empty array. Make sure that the name you choose indicates 'plurality', because an array is capable of containing more than one element. (See [Naming conventions](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md)). -* Write a `console.log` statement that explains in words what you think the value of the array is. -* `console.log` your array. -* Create an array that has your favorite animals inside (see if you can find a good name that exactly describes what this variable will hold). -* Log your array. -* Add a statement that adds 'baby pig' to the *existing array*. -* Log your new array! - -4. Working with strings -Checkout [this article](https://www.digitalocean.com/community/tutorials/how-to-index-split-and-manipulate-strings-in-javascript) for help with working with strings -Let's consider the following string: `let myString = "this is a test"`. - * Find a way to get the length of `myString`. - * `console.log` the length of `myString`. - -5. Working with variable types -* First declare at least four variables and assign them different variable types. -* For each variable write a `console.log` statement that logs the value - ```js - let foo = 3; - console.log('The value of my variable foo is: ' + foo); - ``` - -6. Working with typeof -* Now write a `console.log` statement wherein you first explain in words what you think the _type_ of your variables is. -* Now use `typeof` to log the actual _type_ of your variables. - ---- - -You have finished the warmup exercises, well done! To celebrate lets add the answers to github as a commit, see [Here](##Step-5:-Hand-in-Homework:) how to do that. - -## Step 4: Smart-ease - We help where we can -Enough warm up, lets get to the real problems! We will assume a real world business case where you (the developer) needs to help a business that is starting up (a startup) with solving some of their problems related to JavaScript! Here we go: - ---- - -Lets imagine that we have just started a cool new tech startup called **Smart-ease**. And lets imagine we even have this cool website url: [smart-ease.io](smart-ease.io) Now we are in business! - -At **Smart-ease** we focus on solving real world problems. We venture into the world to help people, and by helping people, we create a sustainable business. - -Cool now lets venture into the world and see which problems we can solve: - -![Adventure](https://media.giphy.com/media/oj2GhTqAIoNIk/giphy.gif) - -### Age-ify (A future age calculator) -> You are talking to a friend who suddently looks at you and asks: "How old will you be in 2045?" Hmm you remember the year you were born and try to do some calculation: Born in 1987 + 3 that's 1990. 90 - 40 is 50 + 5 thats 58. I will be 58! Wow that was painful! Let's fix that by making some code that automatically does this! - -Create two variables called yearOfBirth and yearFuture. Assign these your own age and a futureYear. -What type will these two variables be? Now calculate the age and store that in a variable called age. Log out this string: -"You will be 40 years old in 2027". With 40 being the result of the age variable and 2027 being the yearFuture variable. (Hint use string concatenation) - -### Goodboy-Oldboy (A dog age calculator) (Optional) -> The same friend (who by the way loves dogs) asks how old his dog will be in 2045. Hmm you think, lets make this into a product as well! -Dogs age can either be measured in dog years or in human years, this we want to take into consideration! - -Like before lets create three variables but this time we call them dogYearOfBirth, dogYearFuture and dogYear. We add an extra variable called shouldShowResultInDogYears. If it is true we should show the result in dog years, if it is false we should show it in human years. What do we call this type of variable? Now log this string out: -"Your dog will be 10 human years old in 2027" -or -"Your dog will be 70 dog years old in 2027" - -### Housey pricey (A house price estimator) -> Two of your friends are considering buying a house, but cannot figure out what the right price should be. Your friends know the width, the height and the depth of the house and the garden size. Lets help them figure out if they paid too much: - -We have made our own formula for calculating the price of a house: -```js -housePrice = volumeInMeters * 2.5 * 1000 + gardenSizeInM2 * 300 -``` - -Your friend Peter is considering a house that is 8m wide, 10m deep and 10m high. The garden size is 100m2. The house costs 2.500.000. -Your friend Julia is considering a house that is 5m wide, 11m deep and 8m high. The garden size is 70m2. This house costs 1.000.000. - -Figure out if Peter and Julia are paying too much or too little using javascript and the formula specified above. - - -### Ez Namey (Startup name generator) (Optional) -> At a meetup you overhear a conversation between two developers. It went something like this: "Man i wish picking a startup name was easier! You need to be creative, funny and interesting, its nearly impossible!" Another problem to solve, awesome! - -Lets help people who struggle finding a startup name by creating some code! - -Create two arrays called firstWords, secondWords. The arrays should have 10 elements containing strings of possible startup names. Some examples could be: "Easy", "Awesome", "Corporate". -Create a variable called startupName that will contain created startup name. -Using a random index (you choose) of the arrays and concatenation of strings, create and log the new startup name and the number of characters in it. -An example could be: "The startup: "Easy Corporation" contains 16 characters" - -Hint: you can use this code to generate a random number from 0-9, if you dont want to specify the indexes yourself. -```js -const randomNumber = Math.floor(Math.random() * 10) + 0 -``` ---- - -4 projects from one startup, thats incredible! Lets hope one or more of these projects actually becomes popular! - -To be continued... - - -## Step 5: Hand in Homework: - -Steps: -* Use the hyf-homework repo and add your homework files in the javascript/javascript1/week1 folder -* If you dont have the repo, fork it from here: https://github.com/HackYourFuture-CPH/hyf-homework -* Make your commits for the homework. Remember to seperate the code into meaningful commits! -* Push the changes to github -* To finish the homework: - * Fill in the form for the relevant week. The link to the form can be found at the top of your classes slack channel. - * Share the github link to your classes slack channel. - ---- - -And thats it your are done 🎉 diff --git a/JavaScript1/Week1/preparation.md b/JavaScript1/Week1/preparation.md deleted file mode 100644 index 5fbdf440..00000000 --- a/JavaScript1/Week1/preparation.md +++ /dev/null @@ -1,10 +0,0 @@ -![Reading](https://media.giphy.com/media/l0MYtRl33WaN4HGBq/giphy.gif) - -# Preparation -- [ ] [Read this](http://speakingjs.com/es5/ch01.html) up to and including the *Strings* chapter (it’s okay if you don’t understand all of it yet, we will cover these concepts in class as well. Do make sure to write or document the questions you have so we can discuss them in class) (15 min) - -- [ ] [JavaScript Introduction at MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Introduction) (10 min) - -- [ ] Extra: Go through the [review](review.md) of the this class. (10 min) - -_Please go through the material and come to class prepared!_ \ No newline at end of file diff --git a/JavaScript1/Week1/readme.md b/JavaScript1/Week1/readme.md deleted file mode 100644 index e88a3397..00000000 --- a/JavaScript1/Week1/readme.md +++ /dev/null @@ -1,12 +0,0 @@ -# Week 1 - -## Learning goals -- [ ] Intro JavaScript (What is it, where can you use it for) -- [ ] Variables [var, let, const] -- [ ] Basic Data types [Strings, Numbers, Arrays] -- [ ] Operators - -## Relevant links -* [Preparation](preparation.md) -* [Homework](homework.md) -* [Review](review.md) diff --git a/JavaScript1/Week2/homework.md b/JavaScript1/Week2/homework.md deleted file mode 100644 index e6632bdb..00000000 --- a/JavaScript1/Week2/homework.md +++ /dev/null @@ -1,163 +0,0 @@ -# Homework - -## Step 1: Recap/Read - -- Have a look at [The Secret Life of JavaScript Primitives](https://javascriptweblog.wordpress.com/2010/09/27/the-secret-life-of-javascript-primitives/) -- Go through the review of [last week](../Week1/review.md) (Work in progress, update this week :wrench:) -- Go through the review of [this week](../Week2/review.md) (work in progress, update this week :nut_and_bolt:) - - -## Step 2: Javascript warmup part one -Just like last time, lets warmup our brain! -Go back to FreeCodeCamp, start where you left off and finish the rest of the Basic JavaScript challenges. We know this seems like a lot, but the tasks are not so big, so hang in there! - -Please make sure you REALLY understand the exercises below: - -- https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/store-multiple-values-in-one-variable-using-javascript-arrays/ -- https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/build-javascript-objects/ -- https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/add-new-properties-to-a-javascript-object/ - - -## Step 3: Javascript warmup part two - -1. Create a function that returns an empty object. -2. Create a new variable called ```timeObject``` and assign it to the result of calling the previous function -3. Inside the function, add a key to the object called time with the value of the number 12 -4. Log out ```timeObject```. It should look like this: -```js -{ - time: 12, -} -``` - ---- - -1. Create a function that returns an array with with 3 empty objects. -2. Call the function and assign the return of the function to a variable called ```colorObjects``` (like we did in the previous exercise) -3. Change the array so that all the objects have one key called color. Make every object have a different color -4. Log out ```colorObjects``` -5. Give the function 3 parameters called ```color1```, ```color2``` and ```color3```. The parameters should control the color of the 3 objects. ```color1``` sets the color of the first object and so on. -6. Call the function with 3 colors and log out ```colorObjects```. ```colorObjects`` should look like this: -```js -[{ - color: 'red', -},{ - color: 'blue', -},{ - color: 'yellow', -}] -``` -If the colors you called the function with were red, blue and yellow. - -7. For every object in the array log out the color of the object. Hint use a for loop and read [Here](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/objects.md) to check how to get the value of an object. - ---- - -8. Today is Sunday and you ask your friend in how many days you are meeting. If the friend says -I will see you in 9 days. The output should be Tuesday. You should get the today's day from the system. -So typical console output is: - -``Today is: Sunday`` -``How many days to meet : 9`` -``We are meeting on : Tuesday`` - -Hint: use remainder operator - -## Step 3: Smart-ease - Goes Global! -Following the massive success of Smart-ease's first couple of products things have been quite hectic at Smart-ease's shared office space. The phone is constantly ringing from journalists wanting to interview the genius behind the success and the greatest developers want to work for you. [Wired](www.wired.com) wrote an article with the headline "Smart-ease as good as Smarties" - -BUT people are asking: What will be the next product that truly defines Smart-ease as the startup of the century? - -As always Smart-ease starts by helping people fix their problems. So lets venture out into the real world and see what we find: - -### NOnoN0nOYes (Note taking app) -> You are sitting at a meeting. A person is presenting some interesting thought that you want to write down. You check your bag, but realise that you forgot to bring your notepad. Hmm you check the internet for an online solution. But you need to signup for them all, too bad... Maybe this could be a worthwhile problem so solve. Lets create a simple and easy to use notepad 📝 - -#### Save a note -The first thing we will create is the functionality to save a note: -Create a variable called ```notes``` and assign it to an empty array. -Create a function called ```addNote```. The ```addNote``` has two parameters: ```note``` and ```noteId```. The ```note``` parameter is a string. and the ```noteId``` is a number. -The ```addNote``` function shall push an object to the notes array. This object has two keys: note and noteId, that corresponds to the parameters. The value of the keys should be the value of the corresponding parameters. - -#### Get a note -Now a user can add a note, but what if a user wants to see a specific note, but only remembers the id? Lets create that functionality for him: -Create a function called ```getNoteFromId```. The function has one parameter called ```id```. When calling this function with an id it should return the relevant note object that corresponds to the id. If no id is specified or if the id is not a number, log out an error string. -Hint: Use a for loop. - -#### Read all notes -Now a user can both add and get a note. What if the user just wants to read all his notes? Lets also create that functionality: -Create a function ```showAllNotes```. When calling it the function should log this string out for every note: -"The note with id: 1, has the following note text: "some example note"." - -#### Unique feature -Suddenly you get this great idea for making the note app even better! - -Come up with a unique feature you think would make this app better. Write down the idea and see if you can implement it. If it is too hard to implement try and ask in the slack channel :) - -### CactusIO-interactive (Smart phone usage app) -> After a long day you come home to relax. The first thing you do is find your phone and start watching some youtube. Then check facebook, and then reading some news. Suddently a hour has passed. What happened to all that time you think to yourself. Maybe we can create some program to help with this problem! What if we could help users manage their smart phone usage? - -Its going to work like this: A user can add smartphone activities. Then he can see a status on how his smartphone usage is going. - - -#### Adding an activity -Lets create the first part of the functionality that is adding activities. - -Create a variable called ```activities``` that stores all activities of the day. What type of variable would you think would make sense? -Create a function called ```addActivity```. It should have three parameters: ```date```, ```activity``` and ```duration```. The ```date``` should be a string, the ```activity``` a string and the ```duration``` a number. To save the activity push an object that contains the date, the activity and the duration to the activities variable. - -Now a user can add an activity by writing: -``` -addActivity('23/7-18', 'Youtube', 30); - -/* -activities should now look like this -[{ - date: '23/7-18', - activity: 'Youtube', - duration: 30, -}] -*/ -``` - -Just adding activities wont help the user very much, we need to add some functionality to show the user how his smart phone usage is going. - - -#### Show my status -Create a function called ```showStatus```. This function should use the activities variable and return a string saying the following: -"You have added 3 activities. They amount to 78 min. of usage" -``` -showStatus(activities); // will log out this "You have added 3 activities. They amount to 78 min. of usage" -``` -Now what happens if we call ```showStatus``` and ```activities``` is empty? We need to take that into consideration: If ```activities``` is empty log out a string that says: "Add some activities before calling showStatus" - -#### Usage limit -A user asks us if it is possible to set a limit for his smartphone usage. "Off course it is" we promptly reply! -We need to store that limit somewhere, but where and what type should this be? -So how should it work? When ```showStatus``` is called and the users usage is above the limit he set. Log out the following string: "You have reached your limit, no more smartphoning for you!" - -#### Extra feature -Come up with one feature you think would be helpful for this program. - -Optional -* Lets improve the ```addActivity```, so that we dont need to specify the date, but the function automatically figures out what the date is. Check out this link: https://stackoverflow.com/a/34015511 -* Improve the ```showStatus``` function by only showing the number of actitivies for that specific day. -* Create a function for calculating the activity a user has spent the most time on. ---- - - -## Step 4: Rover the Robot (Optional) -Go and try out this cool game: [roverjs.com](http://roverjs.com), written by one of the HYF teachers from Amsterdam, [Joost Lubach](https://github.com/joost). There are different levels. Solve the chapter up until and including the variables chapter. There might be a small price for completing that! - -## Step 5: Hand in Homework: -Steps: -* Use the ```hyf-homework``` repo and add your homework files in the ```javascript/javascript1/week2``` folder -* If you dont have the repo, fork it from here: https://github.com/HackYourFuture-CPH/hyf-homework -* Make your commits for the homework. Remember to seperate the code into meaningful commits! -* Push the changes to github -* To finish the homework: - * Fill in the form for the relevant week. The link to the form can be found at the top of your classes slack channel. - * Share the github link to your classes slack channel. ---- - -And thats it your are done 🎉 \ No newline at end of file diff --git a/JavaScript1/Week2/preparation.md b/JavaScript1/Week2/preparation.md deleted file mode 100644 index 044435e7..00000000 --- a/JavaScript1/Week2/preparation.md +++ /dev/null @@ -1,15 +0,0 @@ -# Preparation for the second lecture: - -## Read the following articles that are very important to programming! -- [Array](http://javascript.info/array) (10 min) -- [Loops](http://javascript.info/while-for) (10 min) -- [Functions](http://javascript.info/function-basics) (10 min) -- [Another Functions article](http://eloquentjavascript.net/03_functions.html) (25 min) -- [Objects](http://javascript.info/object) (15 min) -- [Conditions](http://javascript.info/ifelse) (5 min) -- [Program structure](http://eloquentjavascript.net/02_program_structure.html) (25 min) - -## Review the topics of week 1: -[Week1 review](../Week1/review.md) (5 min) - -_Please go through the material and come to class prepared!_ diff --git a/JavaScript1/Week2/readme.md b/JavaScript1/Week2/readme.md deleted file mode 100644 index 63a7695d..00000000 --- a/JavaScript1/Week2/readme.md +++ /dev/null @@ -1,16 +0,0 @@ -# Week 2 - -## Learning goals -- [ ] Advanced data types [Objects] -- [ ] Conditions -- [ ] Statements vs Expressions -- [ ] Loops (for/while) -- [ ] Functions -- [ ] Naming conventions - -## Relevant links -* [Preparation](preparation.md) -* [Homework](homework.md) -* [Review](review.md) - - diff --git a/JavaScript1/Week2/review.md b/JavaScript1/Week2/review.md deleted file mode 100644 index 8cc7338e..00000000 --- a/JavaScript1/Week2/review.md +++ /dev/null @@ -1,234 +0,0 @@ -# REVIEW JavaScript week 2 - -``` -This review covers: -• Recap Logical operators -• Typeof -• Loops (for/while) -• Functions -• Advanced data types [Objects] -• Conditions -• Statements vs Expressions -• Naming conventions -``` - -### Recap Logical operators: - -```js -0 = false -1 = true -``` - -#### AND `&&` - -| `&&` |0|1| -|------|-|-| -|0|0|0| -|1|0|1| - -#### OR `||` - -| `\|\|` |0|1| -|------|-|-| -|0|0|1| -|1|1|1| - -So you can say that false in combination with `&&` always returns true -```js -true && false //-> false -false && true //-> false -false || true //-> true -true || false //-> true -``` - -### Typeof - -`typeof` always returns the data type in a string. - -So for example: -```js -let bar = 42; -typeof bar //-> 'number' -typeof typeof bar; //-> 'string' -``` - -So the data type of what `typeof` returns is always a string, bar on the other hand is still a number. - -## Objects - -Variables that are objects also contain a list of things, but instead of them being in some specific order, they can be assigned to words, called "keys". Instead of "elements" the things that are inside objects are called "properties". - - -```js -let obj = {name: 'John', age: 24}; -``` - -This object has two properties: `name` and `age`. The "value" of the property `name` is the string `'John'`. The "value" of the property `age` is the number `24`. - -When accessing object properties, you can use the dot-notation: `obj.name` or the bracket-notation: `obj["name"]`. Note that the latter looks a lot like the way to access array elements. However, here what's inside the bracket (called "key" for objects, instead of "index") must be a string. - -```js -console.log(obj.name); // -> 'John' -console.log(obj['name']); // -> 'John' -``` - -Just like with arrays, you can also use a variable to access properties, as long as these variables are strings. In this case you cannot use the dot-notation! - -```js -var ageKey = 'age'; -console.log(obj[ageKey]); // -> 24 -``` - -Remember that there is a very big difference between `obj[name]` and `obj["name"]`. - -> Note: -> -> Thinking back of arrays, the length of an array can be retrieved by `arr.length`. So as mentioned before, arrays are just like other JavaScript objects. You could even write `arr['length']` to access the `length` property of the array. JavaScript will look: is what we put between brackets a number? Then it is an index and we'll look up the correct array element. If it's a string, it's a key and we will look up the corresponding property. - - -## Functions - -A function is a reusable piece of code. Functions are *very* important in JavaScript, to the extent that some people call JavaScript a "function-oriented" language. As mentioned above, variables can be of type function. In fact, *every function is a variable*. - -The following two pieces of code have the exact same result: - -```js -function sum(a, b) { - return a + b; -} -``` - -and - -```js -let sum = function (a, b) { - return a + b; -} -``` - -> Note -> -> This is not entirely true, as in the second code, the function is "anonymous", i.e. it has no name. But in both cases, you can call the function like this: `sum(4, 5)`. - -### Parameters & arguments - -When writing `function sum(a, b)`, `a` and `b` are the "parameters" of the function. We say that this function has two parameters. (Sometimes, you'll see the word "arity": this function has "arity" 2, but that is something you don't have to use for now.) - -Now, when *calling* function sum, e.g. `var s = sum(4, 5);`, we say that the numbers `4` and `5` are the "arguments" of the function. Arguments are "passed" to the function: "we pass `4` and `5` to the function `sum`". - -So remember the difference between the word "parameter" and "argument". Many people confuse them, and that's not a big problem, but understanding the difference is always nice: - -* A parameter is the name you want to give to the variable that is available inside of the function. -* An argument is the actual value you want to assign to the parameters when you call the function. - -A function that "has two parameters" is also said to "take/accept two arguments". But, sometimes you'll hear people say: "the function has two arguments" or "the function takes two parameters". While formally incorrect, you'll know what they mean. - -### Calling a function on something - -In JavaScript, you can call functions *on* something. By this, we mean that you use the dot to call the function. For instance, when we say "call method `trim` on string `s`", we mean: - -```js -let s = " this is a string "; -s.trim(); // -> "this is a string" -``` - -> Note -> -> Technically, this means that the string `s` will become the `this` special variable inside of the function. - -However, there are functions that you don't call on anything: - -```js -function sum(a, b) { return a + b; } -sum(4, 5); // -> 9 -``` - -Here, you call the function `sum` on nothing. - -Most built-in functions in JavaScript, like math functions or logging functions, also use the dot: - -```js -Math.round(4.5); -console.log("hello"); -Array.from([1, 2, 3]); -``` - -Indeed, these functions are also called "on" `Math`, `console`, `Array`, and so on. However, in this case, their purpose is more to group them logically, so here it's not very important to use that terminology. We'd rather say: "call the function `Math.round` with `4.5` as an argument", i.e. we include it in the full name of the methods. - -It's more when you think about which functions you can call "on" your own variables (strings, arrays, numbers, etc): - -```js -myString.trim(); -myArray.slice(); -myNumber.toString(); -... -``` - - -## Statements & expressions - -Most programming languages that you'll encounter in real life are called "imperative" programming languages. JavaScript is such an imperative programming language. Imperative is another word for command-like. That is, you give the computer a bunch of commands after each other. First do this, then do that, etc. - -These individual commands are called "statements" in imperative programming languages. You can compare them with sentences in the English language. They have a use by themselves, and do not need something else. "The man eats bread." is a full sentence, it conveys a meaning by itself. A sentence in English is always terminated by a period. - -Similarly, a statement in JavaScript should provide a command by itself. JavaScript-statements are (almost always) terminated by a semicolon. - -This is a complete statement: - -```js -let s = "HackYourFuture"; -``` - -It is a full command: declare a variable `s` and initialize it with `"HackYourFuture"`. JavaScript doesn't need any other information to know what we want. The statement is terminated with a semicolon. - -However, this is not a complete statement: - -```js -4 + 5 -``` - -This equals `9`, but what is JavaScript to do with it? It doesn't provide a command. You'd need to do something with it, e.g. `var x = 4 + 5;` or `callFunction(4 + 5)`. We call these parts of statements "expressions". Expressions are not terminated by semicolons. Expressions always "evaluate into a value". In our example, the expression `4 + 5` "evaluates into `9`". If expressions cannot be evaluated into a value, they are invalid. For instance, `4 +` is not a valid expression, it is incomplete, because we need something else after the plus sign. - -So, statements can *contain* expressions. Can expressions contain statements? No, they cannot. However, they can themselves contain expressions. Think about `4 + 5`: it contains the expressions `4` and `5`, as these both evaluate into a value: the expression `4` evaluates into the number `4`, it is a very simple expression. Similarly, `true`, `null`, `undefined` are all expressions. - -### Examples of expressions - -Here are some examples of expressions. Remember: expressions evaluate into a value, but do not provide a command: - -* `sum(a, b)` -* `a` -* `a > 4 ? "yes" : "no"` -* `a + b` -* `a && b || c` -* `arr.length` -* `obj["name"]` -* `[1, 2, 3]` -* `arr[1]` -* `[1]` (this is an array with one element!) -* `function a() { return 4; }` - -The last one requires a bit of explanation. If you write: - -```js -function a() { return 4; } -``` - -by itself, this is a *statement* (a function declaration statement). However, if you write it as part of a statement, such as: - -```js -let b = function a() { return 4; } -``` - -now it is an expression. This is an exceptional situation where something can be a statement or an expression. - -### Examples of not-expressions - -The following are not expressions: - -* `var` -> this is a keyword, see below -* `var x;` -> this is a statement -* `+` -> this is only an operator -* `if (a > 4) { return "yes"; } else { return "no"; }` - -`if` is also a statement. However, it is quite a complex statement. It is also referred to as a "construct", just like `for`, `while`, `try`, etc. - diff --git a/JavaScript1/Week3/homework.md b/JavaScript1/Week3/homework.md deleted file mode 100644 index 15b51c3b..00000000 --- a/JavaScript1/Week3/homework.md +++ /dev/null @@ -1,90 +0,0 @@ -# Homework - -## Step 1: Custom DOM manipulation challenge :mortar_board: - -1. Open a new js file and start by declaring an array that contains 10 strings. These strings should be of book titles you have read (or made up) and be lowercase without spaces or special characters so that you can use these later as Id's. (Example: Harry Potter's - The Chamber of Secrets -> `harry_potter_chamber_secrets`). - -2. Create a basic html file called index.html and use it to load the js file, confirm the console.log show the array. (This is for debugging and making sure everything is in order. Delete it later when you're done :)) - -3. Make a function (or functions) that generate a `ul` with `li` elements for each book ID in the array using a for loop. - -4. Make an object containing information for each book. Each item (object) in this object should have the book ID you thought up in point 1 as a key, and it should have at least the following fields: title, language and author. - -5. Now change the function you used to display the book ID's in a list to take the actual information about the book from the object and display that. Make sure you choose the right html elements for each piece of info, for instance, a heading for the title. - -6. Beautify your html page with css, add sources and alts to each of the images. - -7. Download book covers for each book, construct a new Object which has as keys the bookId's again, and as value the path to the image source (e.g. `{"harry_potter_blabla": "./img/harry_potter_blabla.jpg", ...}`). Now loop over these entries (_hint: `Object.keys(objectName)` gives you an array containing the keys_). Then write a function which places an image at the corresponding `li` element. Remember that Objects are not ordered, so you cannot guarantee that the first key is the first `li` element. (_Hint: you could give each `li` item an `id` tag by modifying the function you made before_) - - -## Step 2: Call stack and parameters - -Write down the call stack at every point where i have made this comment: // draw call stack -Also write down what it logs out. Try and write it down BEFORE you run the code and see if you got it right! - -```js -const watchFirstEpisode = function() { - // draw call stack - console.log('Watch first episode'); -}; - -const watchBreakingBad = function() { - console.log('Watching Breaking bad'); - // draw call stack - watchFirstEpisode(); - console.log('No more for today'); -}; - -const goForARun = function() { - console.log('Im running! look at me!'); -} - -const helpStudentsWithHomework = function() { - console.log('Help help help'); -} - -function finishMondayEvening(functionThatIsParameter) { - functionThatIsParameter(); - // draw call stack - goForARun(); - // draw call stack - helpStudentsWithHomework(); - // draw call stack - console.log('done for today') -} - -// draw call stack -finishMondayEvening(watchBreakingBad); -// draw call stack -``` - - -## Step 3: **FreeCodeCamp challenges:** - -- https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/use-a-constructor-to-create-objects -- https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/extend-constructors-to-receive-arguments -- https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/use-closure-to-protect-properties-within-an-object-from-being-modified-externally - - -And just for fun ... https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-numbers-in-a-range - -## Step 4 bonus homework -the Bonus homework for this week (for those of you want an extra challenge) do the following: - -Go to http://roverjs.com/ and complete the functions and arrays chapters. - -## Step 5: Hand in Homework: -Go over your homework one last time: - -- Does every file run without errors and with the correct results? -- Have you used `const` and `let` and avoided `var`? -- Do the variable, function and argument names you created follow the [Naming Conventions](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md)? -- Is your code well-formatted (see [Code Formatting](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md))? - -If you can answer yes to the above questions then you are ready to hand if the homework: -* Find the hyf-homework git repo (forked from [here](https://github.com/HackYourFuture-CPH/hyf-homework)) -* Add your homework files in the Javascript/javascript1/week3 folder -* To finish the homework use the link in the top of your classes slack channel. ---- - -🎉 diff --git a/JavaScript1/Week3/readme.md b/JavaScript1/Week3/readme.md deleted file mode 100644 index 87e6f92a..00000000 --- a/JavaScript1/Week3/readme.md +++ /dev/null @@ -1,17 +0,0 @@ -# Week 3 - -## Learning goals -- [ ] Functions - - Order of execution - - The call stack -- [ ] Basic DOM manipulations [img src, innerHTML] -- [ ] Code commenting -- [ ] Code debugging using the browser -- [ ] Beautification of code - -## Relevant links -* [Preparation](preparation.md) -* [Homework](homework.md) -* [Review](review.md) - - diff --git a/JavaScript1/readme.md b/JavaScript1/readme.md deleted file mode 100644 index 891d4055..00000000 --- a/JavaScript1/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -## Here you can find course content and homework for the JavaScript 1 module. - -| Week | Topic | Preparation | Homework | Review | -| ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |------------------------------------------------------------------------ | -|1.|• Intro JavaScript (What is it, where can you use it for)
• Variables [var, let, const]
• Basic Data types [Strings, Numbers, Arrays]
• Operators|[Preparation](/JavaScript1/Week1/preparation.md)|[Homework](/JavaScript1/Week1/homework.md)|[Review](/JavaScript1/Week1/review.md)| -|2.|• Advanced data types [Objects]
• Conditions
• Statements vs Expressions
• Loops (for/while)
• Functions
• Naming conventions|[Preparation](/JavaScript1/Week2/readme.md)|[Homework](/JavaScript1/Week2/homework.md)|[Review](/JavaScript1/Week2/review.md)| -|3.|• Functions
• Basic DOM manipulations [img src, innerHTML]
• Code commenting
• Code debugging using the browser
• Beautification of code | [Preparation](/JavaScript1/Week3/readme.md)|[Homework](/JavaScript1/Week3/homework.md)|[Review](/JavaScript1/Week3/review.md) \ No newline at end of file diff --git a/JavaScript2/Week4/homework.md b/JavaScript2/Week4/homework.md deleted file mode 100644 index 30348c7d..00000000 --- a/JavaScript2/Week4/homework.md +++ /dev/null @@ -1,61 +0,0 @@ -# Homework - -First off, congratulations on coming this far, well done! - -## Step 1: Lets get real comfortable with map, filter and sort. - -Use the carGenerator function to generate 10 cars. The file with the function is here: -[carGenerator.js](/JavaScript2/Week4/assets/carGenerator.js) - -You call it like this: -generateCars(10); - -Create the following arrays: - -- 1.1: Cars with speeds between 30 and 60 - -- 1.2: The makes of the cars that are not lightyellow, so the array is going to look like this: ['BMW', 'Fiat'] etc - -- 1.3: Lets change the cars array so it can be read by a danish person. Return an array of objects where the key in the object called speed is called fart (danish for speed), the make is called maerke and the color is called farve. The output will look kind of like this: - -```js -[ - { - maerke: 'Volvo', - fart: 45, - farve: 'lightYellow', - } -]; -``` - - -## Step 2: Some Challenges -Let's practice working with Objects and Arrays. Go to FreeCodeCamp and complete all challenges under "Object Oriented and Functional Programming" and the _first four challenges_ under "Basic Algorithm Scripting", up until 'Find the longest word in a string.' -https://www.freecodecamp.org/challenges/store-multiple-values-in-one-variable-using-javascript-arrays - -## Step 3: Custom challenge -1. Go to https://api.github.com/orgs/HackYourFuture-CPH/repos, you will see a list of the repositories our HYF organization has (yes it's a lot of JSON). -2. You can copy the JSON and put it in a string at the top of your `.js` file use this tool for that: https://jsonformatter.org/. Copy the json text into the jsonformatter and press this key: -> ![Variables are like boxes](./assets/jsonformatter.PNG) -Now you have a json string you can copy into your file. Now print the name of the 3rd github repository to the console. -3. Make a `