diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/JavaScriptHYF.iml b/.idea/JavaScriptHYF.iml
new file mode 100644
index 0000000..0b872d8
--- /dev/null
+++ b/.idea/JavaScriptHYF.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..dfb99cf
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
deleted file mode 100644
index a9a49e4..0000000
--- a/README.md
+++ /dev/null
@@ -1,93 +0,0 @@
-> If you are following the HackYourFuture curriculum we recommend you to start with module 1: [HTML/CSS/GIT](https://github.com/HackYourFuture/HTML-CSS). To get a complete overview of the HackYourFuture curriculum first, click [here](https://github.com/HackYourFuture/curriculum).
-
-> Please help us improve and share your feedback! If you find better tutorials
-> or links, please share them by [opening a pull request](https://github.com/HackYourFuture/JavaScript/pulls).
-
-# Module #2 - JavaScript
-
-
-
-In this module you'll make a start into wonderful world of programming. We will be using the programming language `JavaScript` to do so. You'll learn about the basic building blocks of programming: `loops`, `functions`, `control flow` and more. Consider these as the ABC's of programming, without them it's impossible to write working software!
-
-You'll be learning two main things:
-
-1. **Fundamental concepts in programming**. While we're using JavaScript to illustrate these concepts, it's important to keep in mind that what you will learn is applicable to **any** programming language. They might differ in syntax (a fancy term for the arrangement of words in a language in order for it to make sense), but the functionality will be the same: a loop will always be a loop.
-
-This should be your mindset when you're learning concepts: **I'm learning how to become a software developer that can adjust to any language used, because I know what the underlying principles and concepts are**.
-
-2. **How to think like a programmer**. In one sentence this means: knowing how to solve problems computationally. Let's split that up in two parts: `how to solve problems` refers to the ability to identify issues and find effective solutions. `computationally` refers to the ability to think in logical steps that the computer can understand and execute.
-
-This should be your mindset when you're learning how to think : **I'm learning how to think in logical steps, identifying cause and effect, and always looking for solutions**.
-
-## Before you start!
-
-### Install some new software!
-
-In order to test your JavaScript code, you'll be using software that will execute your files from the command line. This software is called [Node.js](https://nodejs.org/en/download/). Download the Long-Term Support (LTS) version for your specific operating system.
-
-After you've installed it, go to your command line interface. Type in the following command:
-
-```
-node --version
-```
-
-It should show you the version you are working with.
-
-## Learning goals
-
-In order to successfully complete this module you will need to master the following:
-
-- Have an idea of what `computer programming` is
-- Know the basic building blocks of `JavaScript`
-- Correctly write and use `variables`, `functions` and `loops`
-- Understand the `control flow`
-- Be able to solve worded problems using code
-
-## How to use this repository
-
-### Repository content
-
-This repository consists of 2 essential parts for each week:
-
-1. `README`: this document contains all the required theory you need to understand **while** working on the weekly assignment. It contains the list of concepts that you will want to study this week and points you to your study book to read all about them. This is the **first thing** you should start with every week
-2. `MAKEME`: this document contains the instructions for each week's practical tasks / assignment. Start with the exercises rather quickly, so that you can ground the concepts you read about earlier. In the first two weeks we do not expect you to hand in any assignment as the online resources already check the code automatically, from week 3 our mentors will start giving you feedback on your assignments.
-
-### How to study
-
-Let's say you are just starting out with the JavaScript module. This is what you do...
-
-1. The week always starts on **Wednesday**. First thing you'll do is open the `README.md` for that week. For the first week of `JavaScript`, that would be [Week1 Reading](/Week1/README.md)
-2. You spend **Wednesday** and **Thursday** going over the resources and try to get a basic understanding of the concepts. In the meanwhile, you'll also implement any feedback you got on last week's assignment (from the HTML-CSS module)
-3. On **Friday** you start with the assignment, found in the `MAKEME.md`. For the first week of `JavaScript`, that would be [Week1 Assignment](/Week1/MAKEME.md)
-4. You spend **Friday** and **Saturday** playing around with the exercises and write down any questions you might have.
-5. **DEADLINE 1**: You'll submit any questions you might have before **Saturday 23.59**, in the cohort channel.
-6. On **Sunday** you'll attend the Q&A session. It'll be of the Q&A format, meaning that there will be no new material. Instead your questions shall be discussed and you can learn from others.
-7. You spend **Monday** and **Tuesday** finalizing your assignment.
-8. **DEADLINE 2**: You submit your assignment to the right channels (GitHub) before **Tuesday 23.59**. If you can't make it on time, please communicate it with your mentor
-9. Start the new week by going back to point 1!
-
-In summary:
-
-
-
-To have a more detailed overview of the guidelines, please read [this document](https://docs.google.com/document/d/1JUaEbxMQTyljAPFsWIbbLwwvvIXZ0VCHmCCN8RaeVIc/edit?usp=sharing) or ask your mentor/cohort on Slack!
-
-
-## Planning
-
-| Week | Topic | Reading Materials | Assignment |
-| ---- | ---------------------------------------------------------- | --------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
-| 1. | JS Basics Refresher, Loops, Naming Conventions | [Reading W1](/Week1/README.md) | [Assignment W1](/Week1/MAKEME.md) |
-| 2. | Scope, ModernJS, Problem Solving | [Reading W2](/Week2/README.md) | [Assignment W2](/Week2/MAKEME.md) |
-| 3. | Higher Order Functions, Closures, Unit Testing | [Reading W3](/Week3/README.md) | [Assignment W3](/Week3/MAKEME.md) |
-| 4. | This keyword, constructor functions, classes | [Reading W4](/Week4/README.md) | [Assignment W4](/Week4/MAKEME.md) |
-
-## Finished?
-
-Did you finish the module? Good job! You're doing great!
-
-If you feel ready for the next challenge, click [here](https://www.github.com/HackYourFuture/Browsers) to go to Browsers!
-
-_The HackYourFuture curriculum is subject to CC BY copyright. This means you can freely use our materials, but just make sure to give us credit for it :)_
-
-
This work is licensed under a Creative Commons Attribution 4.0 International License.
diff --git a/Week1/MAKEME.md b/Week1/MAKEME.md
deleted file mode 100644
index 7f6f747..0000000
--- a/Week1/MAKEME.md
+++ /dev/null
@@ -1,48 +0,0 @@
-# Assignment JavaScript Week 1
-
-## **Todo list**
-
-1. JS Tutor
-1. Practice the concepts
-1. Prep exercises
-1. Practice practice practice
-
-## **1. JS Tutor**
-
-Practice, practice, practice. This week you are not handing in any assignment, but are going to practice as much javascript as you can. Play around with the exercises mentioned below, remember that you can copy the code into [JS Tutor](http://pythontutor.com/javascript.html#mode=edit) to step through the code. Or look at it in the debugger in the browser/vscode.
-
-## **2. Practice the concepts**
-
-In this section you will be doing interactive exercises, that will allow you to practice with the concepts you've learned about this week! We provide a lot of possible exercises here and you probably can't do everything, but do as many as you need to feel comfortable with the concepts. Also feel free to come back to them later.
-
-- Do all parts of [Codecademy: Arrays](https://www.codecademy.com/courses/introduction-to-javascript/lessons/arrays) (Signup required!)
-- Do 5 exercises of [FreeCodeCamp: Basic data structures](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/#basic-data-structures)
-- [Codecademy: Functions ](https://www.codecademy.com/courses/introduction-to-javascript/lessons/functions)
-- [JSchallenger](https://www.jschallenger.com/) - Do all of the Javascript Basics section except for `scope` and `asynchronous javascript`.
-- There is a practice-exercises folder in this week's repository that is filled with exercises to try out. The solutions are in a separate folder so you can check if you did it correctly. Clone this repository to your computer and have a go!
-
-## **3. Prep exercises**
-
-> Prep exercises are exercises that you should work on _before_ the session on Sunday. These are a little more difficult or show an important concept and as such are a great exercise to talk about with your cohort and your Q&A mentor. Have a solution ready by Sunday as you may be asked to show what you did.
-
-Inside your `JavaScript` fork, go to the folder `Week1`. Inside that folder, navigate to `/prep-exercises`. For each exercise, you will find a separate folder. The `README` explains what needs to be done. There will also be some questions at the bottom to think about. Go through them _before_ the session on Sunday as it will be covered then.
-
-## **4. Practice practice practice**
-
-Done with the above? Then it is time to practice practice practice! Below you will find huge lists of practice exercises to keep practicing. The better you get at JavaScript, the easier the rest of the curriculum is so try to do as much as you can. Some of these solutions use some of the concepts of next week so if something looks weird, have a quick look at next week's topics to see what it means:
-
-- [W3Resource Basic exercises](https://www.w3resource.com/javascript-exercises/javascript-basic-exercises.php) _(Note that the given solutions to these exercises use old JS syntax, we will learn more about this later. Most important now is that we don't use `var` anymore, so make sure you use `let` or `const`!)_
-
-There are also multiple websites that provide constant challenges to practice your skills. These go from beginner to advanced and you should bookmark them and return every once in awhile. In some interview processes these kinds of exercises are given nowadays. We suggest to start with Edabit as they are more geared to beginners, the others start at a higher level:
-
-- [Edabit](https://edabit.com/challenges) - You can choose JavaScript as a language and then try solving as many challenges as you can. If you find the level too easy then you can choose a higher difficulty.
-- [leetcode](https://leetcode.com/) - Sign up and start solving!
-- [Code Wars](https://www.codewars.com/) - Once you feel comfortable with the JavaScript syntax sign up for code wars to practice. It is a website where you can solve exercises and rank up! When signing up, only choose JavaScript to really focus the problems on learning to solve problems in it. You can later change it to other technologies when you get more familiar.
-
-## No assignment to hand in (for now)
-
-For the first week of JavaScript there is no assignment to hand in as the exercises already give you all the feedback you need.
-
-## Done early?
-
-Try to do more exercises in the links above. The first weeks of the JavaScript modules are very important as understanding the basics will make the rest of the curriculum that much easier to follow. So keep reading and writing code!
diff --git a/Week1/QA.md b/Week1/QA.md
deleted file mode 100644
index 3498fcf..0000000
--- a/Week1/QA.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# Q & A Session
-
-The first week of JavaScript we do not have an assignment and we encourage trainees to follow all the material at their own pace. So trainees can ask questions about any week. Expect questions about:
-
-- Functions
-- Basic JavaScript blocks (let/const, operators, loops, if/else, functions)
-- The Debugger (both browser/vscode) and how to debug
-- Naming conventions
-- DRY principle
-
-In these first weeks, we want to get the trainees to create the right mental model for JavaScript constructs, so try to go back to basics as much as possible. However easy it comes to the mentors, this is the first time trainees encounter all the syntax of a programming language. So try to go slowly and use the debugger / [JSTutor](http://pythontutor.com/javascript.html#mode=edit) as much as possible.
diff --git a/Week1/README.md b/Week1/README.md
deleted file mode 100644
index ae62329..0000000
--- a/Week1/README.md
+++ /dev/null
@@ -1,44 +0,0 @@
-# Reading Material JavaScript Week 1
-
-## Agenda
-
-These are the topics for week 1:
-
-1. [Refresher on JavaScript building blocks](https://github.com/HackYourFuture/explore/tree/main/Week3)
- - Variables
- - Values
- - Statements / Expressions
- - Operators
- - Conditional Statements
- - [Functions](https://study.hackyourfuture.net/#/javascript/functions)
-1. [Refresher on debuggers](https://study.hackyourfuture.net/#/tools/debuggers)
-1. [Loops](https://study.hackyourfuture.net/#/javascript/loops)
-1. [Naming conventions](https://study.hackyourfuture.net/#/programming/naming-conventions)
-1. [Testing code](https://www.ministryoftesting.com/articles/e463d4ba?s_id=14519957)
- - [Assertion](https://study.hackyourfuture.net/#/testing/assertion)
-
-## Week goals
-
-All of the detailed information about every concept is in your study book. The following goal explanation will link you to the correct place to get studying. Read through the goal description once to get an idea of what you will be learning, then go through the different links and look at them in detail.
-
-Welcome to week 1 of JavaScript! Time to get coding, let's start with refreshing the things we learned during the explore module. Have a look at [week 3](https://github.com/HackYourFuture/explore/tree/main/Week3) there again to remind yourself what the following concepts mean again:
-
-- Variables
-- Values
-- Statements / Expressions
-- Operators
-- Conditional Statements
-
-Then have a look at functions again over [here](https://study.hackyourfuture.net/#/javascript/functions).
-
-This week we are going to go a little deeper and get some extra building blocks to work with. Another cool thing we can do in JavaScript is repeat actions, we can do that using a concept called loops, read more about that [here](https://study.hackyourfuture.net/#/javascript/loops).
-
-You now have all of the basic building blocks that form the basis of all code! You will undoubtedly already have encountered the difficulty of reading code, and combining everything this week will make it even more difficult to follow. It is a good idea to revisit the debugger section with this new knowledge [here](https://study.hackyourfuture.net/#/tools/debuggers). Although it is called debugging, a lot of the process of finding 'bugs' in your code is trying to understand what is happening in the code. So keep using the debugger to understand pieces of code that you are not 100% comfortable with yet!
-
-This is also the week we are going to start learning about best practices surrounding programming. These are general rules programmers follow so that code remains readable for others. The first will be about naming conventions, read more about that [here](https://study.hackyourfuture.net/#/programming/naming-conventions) and try to make it a habit to follow them.
-
-Lastly we want to introduce the first steps to testing code. Let's first have a look at what software testing is and why we do it [here](https://www.ministryoftesting.com/articles/e463d4ba?s_id=14519957). The simplest form of testing is using assertions, have a look what that is [here](https://study.hackyourfuture.net/#/testing/assertion), we will introduce this more in your assignment so you will see how it works.
-
-## Finished?
-
-Are you finished with going through the materials? You're doing great! If you feel ready to get practical, click [here](./MAKEME.md).
diff --git a/Week1/practice-exercises/1-remove-the-comma.js b/Week1/practice-exercises/1-remove-the-comma.js
deleted file mode 100644
index b71cffd..0000000
--- a/Week1/practice-exercises/1-remove-the-comma.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * We want to remove the comma's in the given string (myString), replace them with a space and log it to the console.
- *
- * The end result should be:
- * hello this is a difficult to read sentence
- */
-
-let myString = 'hello,this,is,a,difficult,to,read,sentence';
-
-
-
-/* --- Code that will test your solution, do NOT change. Write above this line --- */
-
-console.assert(myString === 'hello this is a difficult to read sentence', 'There is something wrong with your solution');
\ No newline at end of file
diff --git a/Week1/practice-exercises/2-even-odd-reporter.js b/Week1/practice-exercises/2-even-odd-reporter.js
deleted file mode 100644
index 6edf23e..0000000
--- a/Week1/practice-exercises/2-even-odd-reporter.js
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * Report whether or not a number is odd/even!
- *
- * Create a for loop, that iterates from 0 to 20.
- * Create a conditional statement that checks if the value of the counter variable is odd or even.
- * If it's odd, log to the console The number [PUT_NUMBER_HERE] is odd!.
- * If it's even, log to the console The number [PUT_NUMBER_HERE] is even!.
- */
-
diff --git a/Week1/practice-exercises/3-recipe-card.js b/Week1/practice-exercises/3-recipe-card.js
deleted file mode 100644
index 24bcb54..0000000
--- a/Week1/practice-exercises/3-recipe-card.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * Ever wondered how to make a certain meal? Let's create a recipe list with JavaScript!
- *
- * Declare a variable that holds an empty object literal (your meal recipe).
- * Give the object 3 properties: a title (string), a servings (number) and an ingredients (array of strings) property.
- * Log each property out separately, using a loop (for, while or do/while)
- *
- * Expected result:
- *
- * Meal name: Omelette
- * Serves: 2
- * Ingredients: 4 eggs, 2 strips of bacon, 1 tsp salt/pepper
- */
-
diff --git a/Week1/practice-exercises/4-reading-list.js b/Week1/practice-exercises/4-reading-list.js
deleted file mode 100644
index f535657..0000000
--- a/Week1/practice-exercises/4-reading-list.js
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * Keep track of which books you read and which books you want to read!
- *
- * Follow the steps:
- * Declare a variable that holds an array of 3 objects, where each object describes a book and has properties for the title (string), author (string), and alreadyRead (boolean indicating if you read it yet).
- * Loop through the array of books.
- * For each book, log the book title and book author like so: "The Hobbit by J.R.R. Tolkien".
- * Create a conditional statement to change the log depending on whether you read it yet or not. If you read it, log a string like You already read "The Hobbit" right after the log of the book details
- * If you haven't read it log a string like You still need to read "The Lord of the Rings"
- */
-
diff --git a/Week1/practice-exercises/5-who-wants-a-drink.js b/Week1/practice-exercises/5-who-wants-a-drink.js
deleted file mode 100644
index f37f02b..0000000
--- a/Week1/practice-exercises/5-who-wants-a-drink.js
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * You're at a party and you feel thirsty! However, you've got 5 friends who are also in need of a drink. Let's go get them a drink.
- *
- * Declare a variable that holds an empty array, called drinkTray.
- * Create a loop that runs 5 times. On each iteration, push a drink into the drinkTray variable. The drinkTray can only hold at most two instances of the same drink type, for example it can only hold 2 colas, 2 lemonades, 2 waters.
- *
- * Log to the console: "Hey guys, I brought a [INSERT VALUES FROM ARRAY]!" (For example: "Hey guys, I brought a cola, cola, lemonade, lemonade, water!")
- */
-
-// There are 3 different types of drinks:
-const drinkTypes = ['cola', 'lemonade', 'water'];
\ No newline at end of file
diff --git a/Week1/practice-exercises/solutions/1-remove-the-comma.js b/Week1/practice-exercises/solutions/1-remove-the-comma.js
deleted file mode 100644
index 0839202..0000000
--- a/Week1/practice-exercises/solutions/1-remove-the-comma.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * We want to remove the comma's in the given string (myString), replace them with a space and log it to the console.
- *
- * The end result should be:
- * hello this is a difficult to read sentence
- */
-
-let myString = 'hello,this,is,a,difficult,to,read,sentence';
-
-myString = myString.split(',').join(' ');
-
-/* --- Code that will test your solution, do NOT change. Write above this line --- */
-
-console.assert(myString === 'hello this is a difficult to read sentence', 'There is something wrong with your solution');
\ No newline at end of file
diff --git a/Week1/practice-exercises/solutions/2-even-odd-reporter.js b/Week1/practice-exercises/solutions/2-even-odd-reporter.js
deleted file mode 100644
index 520d16a..0000000
--- a/Week1/practice-exercises/solutions/2-even-odd-reporter.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * Report whether or not a number is odd/even!
- *
- * Create a for loop, that iterates from 0 to 20.
- * Create a conditional statement that checks if the value of the counter variable is odd or even.
- * If it's odd, log to the console The number [PUT_NUMBER_HERE] is odd!.
- * If it's even, log to the console The number [PUT_NUMBER_HERE] is even!.
- */
-
-for (let i = 0; i < 21; i++) {
- if (i % 2 == 0) {
- console.log(`The number ${i} is even!`);
- } else {
- console.log(`The number ${i} is odd!`);
- }
-}
\ No newline at end of file
diff --git a/Week1/practice-exercises/solutions/3-recipe-card.js b/Week1/practice-exercises/solutions/3-recipe-card.js
deleted file mode 100644
index 4ae2b7a..0000000
--- a/Week1/practice-exercises/solutions/3-recipe-card.js
+++ /dev/null
@@ -1,17 +0,0 @@
-const myRecipe = {
- title: 'Omelette',
- servings: 2,
- ingredients: ['4 eggs', '2 strips of bacon', '1 tsp salt/pepper'],
-};
-
-for (let item in myRecipe) {
- if (item == 'title') {
- console.log(`Meal name: ${myRecipe[item]}`);
- } else if (item == 'servings') {
- console.log(`Serves: ${myRecipe[item]}`);
- } else {
- const ingredientList = myRecipe[item];
-
- console.log(`Ingedients: ${ingredientList.join(', ')}`);
- }
-}
\ No newline at end of file
diff --git a/Week1/practice-exercises/solutions/4-reading-list.js b/Week1/practice-exercises/solutions/4-reading-list.js
deleted file mode 100644
index 6d70fb3..0000000
--- a/Week1/practice-exercises/solutions/4-reading-list.js
+++ /dev/null
@@ -1,27 +0,0 @@
-const listOfBooks = [
- {
- title: 'Hard Times',
- author: 'Charles Dickens',
- alreadyRead: true
- },
- {
- title: 'The Grapes of Wrath',
- author: 'John Steinbeck',
- alreadyRead: true
- },
- {
- title: 'The Fellowship of the Ring',
- author: 'Peter Jackson',
- alreadyRead: false
- }
-];
-
-for (let bookIndex in listOfBooks) {
- const book = listOfBooks[bookIndex];
-
- if (book.alreadyRead) {
- console.log(`${book.title} by ${book.author}. You already read "${book.title}".`);
- } else {
- console.log(`${book.title} by ${book.author}. You still need to read "${book.title}".`);
- }
-}
\ No newline at end of file
diff --git a/Week1/practice-exercises/solutions/5-who-wants-a-drink.js b/Week1/practice-exercises/solutions/5-who-wants-a-drink.js
deleted file mode 100644
index 5db1ea2..0000000
--- a/Week1/practice-exercises/solutions/5-who-wants-a-drink.js
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * You're at a party and you feel thirsty! However, you've got 5 friends who are also in need of a drink. Let's go get them a drink.
- *
- * Declare a variable that holds an empty array, called drinkTray.
- * Create a loop that runs 5 times. On each iteration, push a drink into the drinkTray variable. The drinkTray can only hold at most two instances of the same drink type, for example it can only hold 2 colas, 2 lemonades, 2 waters.
- *
- * Log to the console: "Hey guys, I brought a [INSERT VALUES FROM ARRAY]!" (For example: "Hey guys, I brought a cola, cola, lemonade, lemonade, water!")
- */
-
-// There are 3 different types of drinks:
-const drinkTypes = ['cola', 'lemonade', 'water'];
-const drinkTray = [];
-
-// This is one way of doing it, there are many more. It hopefully showcases a nice use case of the double for loop
-// It could also have been written with a while loop that would be a little more efficient
-for (let i = 0; i < drinkTypes.length; i++) {
- for (let j = 0; j < 2; j++) {
- if (drinkTray.length < 5) {
- drinkTray.push(drinkTypes[i]);
- }
- }
-}
-
-console.log(`Hey guys, I brought a ${drinkTray.join(', ')}!`);
\ No newline at end of file
diff --git a/Week1/prep-exercises/1-traffic-light/README.md b/Week1/prep-exercises/1-traffic-light/README.md
deleted file mode 100644
index d994741..0000000
--- a/Week1/prep-exercises/1-traffic-light/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# Prep exercise - traffic light
-
-Let's have a deeper look at the working of traffic lights this week so that we can practice logic and loops. In `traffic-light-1.js` and `traffic-light-2.js` you will find the same requirements but with different ways of representing the traffic light. Have a look through the files and solve them so you can see how the way we represent data affects the way we need to solve problems.
-
-## Things to think about
-
-- Which way of representing the traffic light did you find better? Why?
-- What happens if you change the loop to a `do-while` loop instead of a `while` loop? Why?
-- We could have also used a `for` loop to make the traffic light do 2 full rotations. Do you think that would be better? Why or why not?
diff --git a/Week1/prep-exercises/1-traffic-light/traffic-light-1.js b/Week1/prep-exercises/1-traffic-light/traffic-light-1.js
deleted file mode 100644
index f1d9169..0000000
--- a/Week1/prep-exercises/1-traffic-light/traffic-light-1.js
+++ /dev/null
@@ -1,31 +0,0 @@
-"use strict";
-/**
- * The `state` property says what the traffic light's state (i.e. colour) is at
- * that moment.
- */
-const trafficLight = {
- state: "green",
-};
-
-let rotations = 0;
-while (rotations < 2) {
- const currentState = trafficLight.state;
- console.log("The traffic light is on", currentState);
-
- // TODO
- // if the color is green, turn it orange
- // if the color is orange, turn it red
- // if the color is red, add 1 to rotations and turn it green
-}
-
-/**
- * The output should be:
-
-The traffic light is on green
-The traffic light is on orange
-The traffic light is on red
-The traffic light is on green
-The traffic light is on orange
-The traffic light is on red
-
-*/
diff --git a/Week1/prep-exercises/1-traffic-light/traffic-light-2.js b/Week1/prep-exercises/1-traffic-light/traffic-light-2.js
deleted file mode 100644
index 8c6ba95..0000000
--- a/Week1/prep-exercises/1-traffic-light/traffic-light-2.js
+++ /dev/null
@@ -1,33 +0,0 @@
-"use strict";
-/**
- * The `possibleStates` property define the states (in this case: colours)
- * in which the traffic light can be.
- * The `stateIndex` property indicates which of the possible states is current.
- */
-const trafficLight = {
- possibleStates: ["green", "orange", "red"],
- stateIndex: 0,
-};
-
-let cycle = 0;
-while (cycle < 2) {
- const currentState = trafficLight.possibleStates[trafficLight.stateIndex];
- console.log("The traffic light is on", currentState);
-
- // TODO
- // if the color is green, turn it orange
- // if the color is orange, turn it red
- // if the color is red, add 1 to cycles and turn it green
-}
-
-/**
- * The output should be:
-
-The traffic light is on green
-The traffic light is on orange
-The traffic light is on red
-The traffic light is on green
-The traffic light is on orange
-The traffic light is on red
-
-*/
diff --git a/Week2/MAKEME.md b/Week2/MAKEME.md
deleted file mode 100644
index ca85c57..0000000
--- a/Week2/MAKEME.md
+++ /dev/null
@@ -1,36 +0,0 @@
-# Assignment JavaScript Week 2
-
-This will be the first week you are expected to hand in an assignment when we combine all of the concepts you have been practicing the last 3 weeks.
-
-## **Todo list**
-
-1. Prep exercises
-1. Assignment
-1. Practice practice practice
-
-## **1. Prep exercises**
-
-> Prep exercises are exercises that you should work on _before_ the session on Sunday. These are a little more difficult or show an important concept and as such are a great exercise to talk about with your cohort and your Q&A mentor. Have a solution ready by Sunday as you may be asked to show what you did.
-
-Inside your `JavaScript` fork, go to the folder `Week2`. Inside of that folder, navigate to `/prep-exercises`. For each exercise, you will find a separate folder. The `README` explains what needs to be done. There will also be some questions at the bottom to think about. Go through them _before_ the session on Sunday as it will be covered then.
-
-## **2. Assignment**
-
-It is time to combine everything we have learned the past couple of weeks and get some feedback from experienced developers. This will be the first week you are working with the assignment repository so reserve some time to set it up. You will find the repository in our [HackYourAssignment](https://github.com/HackYourAssignment/) GitHub page. There should be one called Assignment-cohortXX where XX is your cohort number, you will want to fork that to your own GitHub. Have a look at the [Assignment guide](../hand-in-assignments-guide.md) to see how to hand in your assignment.
-
-This week we expect you to do the exercises in the corresponding module/week folder (JavaScript / Week 2).
-
-_NOTE: Make sure to read and apply all of the steps in the README in the assignment repository to set up the extensions in Visual Studio Code!_.
-
-## **3. Practice practice practice**
-
-Done with the above? Then it is time to practice practice practice! Below you will find huge lists of practice exercises to keep practicing. The better you get at JavaScript, the easier the rest of the curriculum is so try to do as much as you can. Some of these solutions use some of the concepts of next week so if something looks weird, have a quick look at next week's topics to see what it means:
-
-- [JSchallenger](https://www.jschallenger.com/) - Do the `scope` part in the `Basics` section. Then do the following in the Javascript Practice section (fundamentals, arrays, objects).
-- [W3Resource - JavaScript Fundamental exercises](https://www.w3resource.com/javascript-exercises/fundamental/index.php)
-
-Also keep going with all of the from beginner to advanced platforms mentioned last week!
-
-## Done early?
-
-Try to do more exercises in the links above. The first weeks of the JavaScript modules are very important as understanding the basics will make the rest of the curriculum that much easier to follow. So keep reading and writing code!
diff --git a/Week2/QA.md b/Week2/QA.md
deleted file mode 100644
index 55aea31..0000000
--- a/Week2/QA.md
+++ /dev/null
@@ -1,10 +0,0 @@
-# Q & A session
-
-This week we are going deeper into more advanced topics, so expect questions about:
-
-- Scope
-- The Debugger (both browser/vscode) and how to debug functions
-- DRY principle
-- Naming conventions
-
-In these first weeks we want to get the trainees to create the right mental model for JavaScript constructs, so try to go back to basics as much as possible. However easy it comes to the mentors, this is the first time trainees encounter all the syntax of a programming language. So try to go slowly and use the debugger / [JSTutor](http://pythontutor.com/javascript.html#mode=edit) as much as possible.
diff --git a/Week2/README.md b/Week2/README.md
deleted file mode 100644
index 3feb55c..0000000
--- a/Week2/README.md
+++ /dev/null
@@ -1,21 +0,0 @@
-# Reading Material JavaScript Week 2
-
-## Agenda
-
-These are the topics for week 2:
-
-1. [Scope](https://study.hackyourfuture.net/#/javascript/scope)
-1. [Modern JS](https://study.hackyourfuture.net/#/javascript/modern-js)
-1. [Problem solving](https://study.hackyourfuture.net/#/programming/problem-solving-process)
-
-## Week goals
-
-Functions bring along with them a concept called the scope that you may have encountered a bit already but we want to explicitly explain now. Read about scope [here](https://study.hackyourfuture.net/#/javascript/scope).
-
-We have to confess we also kept something else from you until now, JavaScript has different versions. JavaScript has been evolving over its lifetime and certain syntax has been added. Have a look in your study book at the topic of what is called 'Modern JS' [here](https://study.hackyourfuture.net/#/javascript/modern-js). Throughout the curriculum we will be expecting you to use the modern syntax as that is most likely what you will be programming in. You can skip the sections that are about Promises and async/await for now, we will get there in the Using API's module. There is also a section on the history of JavaScript in there, you do not need to know this but we recommend it if you have some time to spare as it is very interesting.
-
-Now that we are getting into more and more complex code it is also a good idea to learn a structured way to solve more complex problems. Have a look at the page on problem solving in your study book over [here](https://study.hackyourfuture.net/#/programming/problem-solving-process).
-
-## Finished?
-
-Are you finished with going through the materials? Give yourself a pat on the back because you rock! It is time to combine everything you have learned and start practicing them vigorously. Have a look at the exercises [here](./MAKEME.md) and try to make as many of them as you can. This week there will be an assignment to do and hand in, so don't forget to do that! If you haven't set up the assignment repository yet, have a look at your class repo.
diff --git a/Week2/prep-exercises/1-traffic-light/README.md b/Week2/prep-exercises/1-traffic-light/README.md
deleted file mode 100644
index b3c3748..0000000
--- a/Week2/prep-exercises/1-traffic-light/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# Prep exercise - Traffic light
-
-In the previous week we started with our traffic light. Now that we also know what a function is we have one last look at the workings of a traffic light in a different way. Take a look at the `traffic-light.js` file and implement the same requirements as last week again, but then with another different way of organising.
-
-## Things to think about
-
-- This time the loop was changed to a for loop that will run the code 6 times. Why was that needed?
-- Why was the trafficLight added to the `main` function and not left at the top of the file?
-- What do you think is the advantage of having the `getCurrentTrafficLightState` and `getNextStateIndex` functions?
diff --git a/Week2/prep-exercises/1-traffic-light/traffic-light.js b/Week2/prep-exercises/1-traffic-light/traffic-light.js
deleted file mode 100644
index f4a5c1a..0000000
--- a/Week2/prep-exercises/1-traffic-light/traffic-light.js
+++ /dev/null
@@ -1,60 +0,0 @@
-"use strict";
-/**
- * The `trafficLight` object is now no longer a global variable. Instead,
- * it is defined in function `main()` and passed as a parameter to other
- * functions, as and when needed.
- */
-
-function getCurrentState(trafficLight) {
- // TODO
- // Should return the current state (i.e. colour) of the `trafficLight`
- // object passed as a parameter.
-}
-
-function getNextStateIndex(trafficLight) {
- // TODO
- // Return the index of the next state of the `trafficLight` such that:
- // - if the color is green, it will turn to orange
- // - if the color is orange, it will turn to red
- // - if the color is red, it will turn to green
-}
-
-// This function loops for the number of seconds specified by the `secs`
-// parameter and then returns.
-// IMPORTANT: This is not the recommended way to implement 'waiting' in
-// JavaScript. You will learn better ways of doing this when you learn about
-// asynchronous code.
-function waitSync(secs) {
- const start = Date.now();
- while (Date.now() - start < secs * 1000) {
- // nothing do to here
- }
-}
-
-function main() {
- const trafficLight = {
- possibleStates: ["green", "orange", "red"],
- stateIndex: 0,
- };
-
- for (let cycle = 0; cycle < 6; cycle++) {
- const currentState = getCurrentState(trafficLight);
- console.log(cycle, "The traffic light is now", currentState);
-
- waitSync(1); // Wait a second before going to the next state
- trafficLight.stateIndex = getNextStateIndex(trafficLight);
- }
-}
-
-main();
-/**
- * The output should be:
-
-0 The traffic light is now green
-1 The traffic light is now orange
-2 The traffic light is now red
-3 The traffic light is now green
-4 The traffic light is now orange
-5 The traffic light is now red
-
-*/
diff --git a/Week2/prep-exercises/2-experiments/README.md b/Week2/prep-exercises/2-experiments/README.md
deleted file mode 100644
index a0e63ca..0000000
--- a/Week2/prep-exercises/2-experiments/README.md
+++ /dev/null
@@ -1,14 +0,0 @@
-# Prep exercises - Dice experimentation
-
-Let's do some experiments! One thing computers are great at is doing the same thing over and over and over again, so let's use that to see how random the random function in JavaScript is. In the `index.js` there is an explanation of what to implement. In essence we want to simulate the rolling of a die a lot of times and then track how many times a certain value was rolled.
-
-For a fair die the chance of rolling a certain value should be equal for all possible values. When rolling a six-sided die many times we therefore expect the number of times each value is thrown to approach 16.6% (1/6) of the total number of rolls. The more rolls we do the closer we should get to the expected value, following the [Law of large numbers](https://en.wikipedia.org/wiki/Law_of_large_numbers).
-
-> Wikipedia: _In probability theory, the law of large numbers (LLN) is a theorem that describes the result of performing the same experiment a large number of times. According to the law, the average of the results obtained from a large number of trials should be close to the expected value and tends to become closer to the expected value as more trials are performed._
-
-In this prep exercise we are using the `Math.random()` function to simulate throwing a die. So what we are actually testing here is how well `Math.random()` distributes its values evenly across the range of 0 to 1 when called many times. We will do this for an increasing number of rolls (`sampleSize` in the code) and expect the results to even out to 16.6% across all values.
-
-## Things to think about
-
-- The `valueCounts` is implemented as an array. Do you think there is another way to store this? Why do you think the decision was made to go with an array?
-- What do you think about the code division? Would you add another function or maybe remove one? Why?
diff --git a/Week2/prep-exercises/2-experiments/index.js b/Week2/prep-exercises/2-experiments/index.js
deleted file mode 100644
index 7e5aa92..0000000
--- a/Week2/prep-exercises/2-experiments/index.js
+++ /dev/null
@@ -1,46 +0,0 @@
-"use strict";
-
-function runExperiment(sampleSize) {
- const valueCounts = [0, 0, 0, 0, 0, 0];
-
- // TODO
- // Write a for loop that iterates `sampleSize` times (sampleSize is a number).
- // In each loop iteration:
- //
- // 1. Generate a random integer between 1 and 6 (as if throwing a six-sided die).
- // 2. Add `1` to the element of the `valueCount` that corresponds to the random
- // value from the previous step. Use the first element of `valueCounts`
- // for keeping a count how many times the value 1 is thrown, the second
- // element for value 2, etc.
-
- const results = [];
-
- // TODO
- // Write a for..of loop for the `valueCounts` array created in the previous
- // loop. In each loop iteration:
- // 1. For each possible value of the die (1-6), compute the percentage of how
- // many times that value was thrown. Remember that the first value of
- // `valueCounts` represent the die value of 1, etc.
- // 2. Convert the computed percentage to a number string with a precision of
- // two decimals, e.g. '14.60'.
- // 3. Then push that string onto the `results` array.
-
- return results;
-}
-
-function main() {
- const sampleSizes = [100, 1000, 1000000];
-
- // TODO
- // Write a for..of loop that calls the `runExperiment()` function for each
- // value of the `sampleSizes` array.
- // Log the results of each experiment as well as the experiment size to the
- // console.
- // The expected output could look like this:
- //
- // [ '26.00', '17.00', '10.00', '19.00', '16.00', '12.00' ] 100
- // [ '14.60', '17.10', '19.30', '15.50', '16.70', '16.80' ] 1000
- // [ '16.71', '16.68', '16.69', '16.66', '16.67', '16.59' ] 1000000
-}
-
-main();
diff --git a/Week3/challenges/1-sum-entries.js b/Week3/challenges/1-sum-entries.js
index f7dd419..cec39f7 100644
--- a/Week3/challenges/1-sum-entries.js
+++ b/Week3/challenges/1-sum-entries.js
@@ -9,9 +9,15 @@ Once you have found those numbers, multiply the numbers and store the result of
const list = [1721, 979, 366, 299, 675, 1456];
let result;
-
-// Write your code here
-
+list.forEach((num, inx) => {
+ for (let i = inx++; i < list.length; i++) {
+ if ((num + list[i]) === 2020) {
+ result = num * list[i];
+ }
+ }
+})
+// I clarify that I have solved the task in my own way, but then I just liked how well
+// it was written in solutions so I re-wrote it the same way
// TEST CODE, do not change
console.assert(result === 514579, `The result is not correct, it is ${result}, but should be 514579`);
\ No newline at end of file
diff --git a/Week3/challenges/2-sum-three-entries.js b/Week3/challenges/2-sum-three-entries.js
index f5f8773..cec799a 100644
--- a/Week3/challenges/2-sum-three-entries.js
+++ b/Week3/challenges/2-sum-three-entries.js
@@ -11,7 +11,15 @@ const list = [1721, 979, 366, 299, 675, 1456];
let result;
// Write your code here
-
+list. forEach((num, inx) => {
+ for (let i = inx++; i < list.length; i++) {
+ for (let j = inx + 2; j < list.length; j++) {
+ if (num + list[i] + list[j] === 2020) {
+ result = num * list[i] * list[j];
+ }
+ }
+ }
+})
// TEST CODE, do not change
console.assert(result === 241861950, `The result is not correct, it is ${result}, but should be 241861950`);
\ No newline at end of file
diff --git a/Week3/challenges/3-password-validation.js b/Week3/challenges/3-password-validation.js
index fa7ad11..2497bb0 100644
--- a/Week3/challenges/3-password-validation.js
+++ b/Week3/challenges/3-password-validation.js
@@ -20,4 +20,15 @@ const passwordList = [
{ times: '1-3', letter: 'a', password: 'abcde'},
{ times: '1-3', letter: 'b', password: 'cdefg'},
{ times: '2-9', letter: 'c', password: 'ccccccccc'}
-];
\ No newline at end of file
+];
+
+passwordList.forEach(passwordData => {
+ const occurrence = passwordData.password.split(passwordData.letter).length - 1;
+ const [min, max] = passwordData.times.split('-').map(Number);
+ if (min <= occurrence && occurrence <= max) {
+ console.log(`${passwordData.password} is VALID, ${passwordData.letter} is present ${occurrence} times and should have been present at least ${min} and at most ${max}`);
+ }
+ else {
+ console.log(`${passwordData.password} is INVALID, ${passwordData.letter} is present ${occurrence} times and should have been present at least ${min} and at most ${max}`);
+ }
+})
\ No newline at end of file
diff --git a/Week3/challenges/4-bank-account.js b/Week3/challenges/4-bank-account.js
index 8f0f035..94860c7 100644
--- a/Week3/challenges/4-bank-account.js
+++ b/Week3/challenges/4-bank-account.js
@@ -28,10 +28,26 @@ const bankAccount = {
};
const donateMoney = (amount, onSuccess, onFail) => {
- // TODO complete this function
+ const obj = bankAccount.transactions[0];
+ if ((bankAccount.currentBalance - amount) < 0) {
+ onFail()
+ }
+ else {
+ onSuccess()
+ bankAccount.transactions.push({...obj, prevAmount: bankAccount.currentBalance, newAmount: (bankAccount.currentBalance - amount), reason: "Donation"});
+ bankAccount.currentBalance = bankAccount.currentBalance - amount;
+ }
};
const payRent = (amount, onSuccess, onFail) => {
- // TODO complete this function
+ const obj = bankAccount.transactions[0];
+ if ((bankAccount.currentBalance - amount) < 0) {
+ onFail()
+ }
+ else {
+ onSuccess()
+ bankAccount.transactions.push({...obj, prevAmount: bankAccount.currentBalance, newAmount: (bankAccount.currentBalance - amount), reason: "Rent"});
+ bankAccount.currentBalance = bankAccount.currentBalance - amount;
+ }
};
/**
diff --git a/Week3/prep-exercises/1-hyf-program/1-find-mentors.js b/Week3/prep-exercises/1-hyf-program/1-find-mentors.js
index 72baa61..0d34cc5 100644
--- a/Week3/prep-exercises/1-hyf-program/1-find-mentors.js
+++ b/Week3/prep-exercises/1-hyf-program/1-find-mentors.js
@@ -8,10 +8,11 @@ import { modules, students, mentors, classes } from "./hyf.js";
* ['John', 'Mary']
*/
const possibleMentorsForModule = (moduleName) => {
- // TODO complete this function
+ return mentors.filter(mentor => mentor.canTeach.includes(moduleName))
+ .map(mentor => mentor.name);
};
// You can uncomment out this line to try your function
-// console.log(possibleMentorsForModule('using-apis'));
+console.log(possibleMentorsForModule('using-apis'));
/**
* Tjebbe wants to make it even easier for himself.
@@ -20,7 +21,8 @@ const possibleMentorsForModule = (moduleName) => {
* It should return a single name.
*/
const findMentorForModule = (moduleName) => {
- // TODO complete this function
+ const array = possibleMentorsForModule(moduleName);
+ return array[Math.floor(Math.random() * array.length)];
};
// You can uncomment out this line to try your function
-// console.log(findMentorForModule('javascript'));
+console.log(findMentorForModule('javascript'));
\ No newline at end of file
diff --git a/Week3/prep-exercises/1-hyf-program/2-class-list.js b/Week3/prep-exercises/1-hyf-program/2-class-list.js
index 44d2798..51cecce 100644
--- a/Week3/prep-exercises/1-hyf-program/2-class-list.js
+++ b/Week3/prep-exercises/1-hyf-program/2-class-list.js
@@ -3,7 +3,7 @@ import { modules, students, mentors, classes } from "./hyf.js";
/**
* We would like to have a list of everyone that is currently participating in a class.
* This means the students, but also the mentors that are currently teaching the class.
- * The students should be self explanatory, but to find the mentors you will need to follow these steps:
+ * The students should be self-explanatory, but to find the mentors you will need to follow these steps:
* - Check what the `currentModule` of the class is
* - Find the mentor(s) that are `nowTeaching` that module
*
@@ -12,10 +12,16 @@ import { modules, students, mentors, classes } from "./hyf.js";
* [{ name: 'John', role: 'student' }, { name: 'Mary', role: 'mentor' }]
*/
const getPeopleOfClass = (className) => {
- // TODO complete this function
+ let foundStudent = students.filter(x => x.class.includes(className))
+ .filter(y => y.graduated !== true)
+ .map(x => ({name: x.name, role: 'student'}));
+ let module = classes.filter(x => x.name.includes(className)).map(x => x.currentModule);
+ let foundMentor = mentors.filter(x => x.nowTeaching === module[0]).map(x => ({name: x.name, role: 'mentor'}));
+ let classComposition = [foundStudent[0], foundMentor[0]]
+ return classComposition
};
// You can uncomment out this line to try your function
-// console.log(getPeopleOfClass('class34'));
+console.log(getPeopleOfClass('class34'));
/**
* We would like to have a complete overview of the current active classes.
@@ -30,7 +36,13 @@ const getPeopleOfClass = (className) => {
* }
*/
const getActiveClasses = () => {
- // TODO complete this function
+ let activeClassesList = classes.filter(x => x.active === true)
+ .map(x => x.name);
+ let result = {};
+ activeClassesList.map(x => {
+ result[x] = getPeopleOfClass(x)
+ })
+ return result
};
// You can uncomment out this line to try your function
-// console.log(getActiveClasses());
+console.log(getActiveClasses());
\ No newline at end of file
diff --git a/Week4/prep-exercises/1-wallet/ex2-classes.js b/Week4/prep-exercises/1-wallet/ex2-classes.js
index f016137..8ee25ea 100644
--- a/Week4/prep-exercises/1-wallet/ex2-classes.js
+++ b/Week4/prep-exercises/1-wallet/ex2-classes.js
@@ -7,6 +7,8 @@ class Wallet {
constructor(name, cash) {
this.#name = name;
this.#cash = cash;
+ this.dailyAllowance = 40;
+ this.dayTotalWithdrawals = 0;
}
get name() {
@@ -23,20 +25,37 @@ class Wallet {
return 0;
}
+ if (this.dayTotalWithdrawals + amount > this.dailyAllowance) {
+ console.log(`Insufficient remaining daily allowance!`);
+ return 0;
+ }
+
this.#cash -= amount;
+ this.dayTotalWithdrawals += amount;
return amount;
}
transferInto(wallet, amount) {
console.log(
- `Transferring ${eurosFormatter.format(amount)} from ${this.name} to ${
- wallet.name
- }`
+ `Transferring ${eurosFormatter.format(
+ amount
+ )} from ${this.name} to ${wallet.name}`
);
const withdrawnAmount = this.withdraw(amount);
wallet.deposit(withdrawnAmount);
}
+ resetDailyAllowance() {
+ this.dayTotalWithdrawals = 0;
+ }
+
+ setDailyAllowance(newAllowance) {
+ this.dailyAllowance = newAllowance;
+ console.log(
+ `Daily allowance set to: ${eurosFormatter.format(newAllowance)}`
+ );
+ }
+
reportBalance() {
console.log(
`Name: ${this.name}, balance: ${eurosFormatter.format(this.#cash)}`
diff --git a/Week4/prep-exercises/1-wallet/ex3-object.js b/Week4/prep-exercises/1-wallet/ex3-object.js
index e94faac..cf18e11 100644
--- a/Week4/prep-exercises/1-wallet/ex3-object.js
+++ b/Week4/prep-exercises/1-wallet/ex3-object.js
@@ -4,6 +4,8 @@ function createWallet(name, cash = 0) {
return {
_name: name,
_cash: cash,
+ dailyAllowance : 40,
+ dayTotalWithdrawals : 0,
deposit: function (amount) {
this._cash += amount;
@@ -14,8 +16,13 @@ function createWallet(name, cash = 0) {
console.log(`Insufficient funds!`);
return 0;
}
+ if (this.dayTotalWithdrawals + amount > this.dailyAllowance) {
+ console.log(`Insufficient remaining daily allowance!`);
+ return 0;
+ }
this._cash -= amount;
+ this.dayTotalWithdrawals += amount;
return amount;
},
@@ -29,6 +36,17 @@ function createWallet(name, cash = 0) {
wallet.deposit(withdrawnAmount);
},
+ setDailyAllowance(newAllowance) {
+ this.dailyAllowance = newAllowance;
+ console.log(
+ `Daily allowance set to: ${eurosFormatter.format(newAllowance)}`
+ );
+ },
+
+ resetDailyAllowance() {
+ this.dayTotalWithdrawals = 0;
+ },
+
reportBalance: function () {
console.log(
`Name: ${this._name}, balance: ${eurosFormatter.format(this._cash)}`
diff --git a/Week4/prep-exercises/1-wallet/ex4-object-shared-methods.js b/Week4/prep-exercises/1-wallet/ex4-object-shared-methods.js
index bd4fd20..bc083d7 100644
--- a/Week4/prep-exercises/1-wallet/ex4-object-shared-methods.js
+++ b/Week4/prep-exercises/1-wallet/ex4-object-shared-methods.js
@@ -9,8 +9,13 @@ function withdraw(amount) {
console.log(`Insufficient funds!`);
return 0;
}
+ if (this.dayTotalWithdrawals + amount > this.dailyAllowance) {
+ console.log(`Insufficient remaining daily allowance!`);
+ return 0;
+ }
this._cash -= amount;
+ this.dayTotalWithdrawals += amount;
return amount;
}
@@ -24,6 +29,17 @@ function transferInto(wallet, amount) {
wallet.deposit(withdrawnAmount);
}
+function setDailyAllowance(newAllowance) {
+ this.dailyAllowance = newAllowance;
+ console.log(
+ `Daily allowance set to: ${eurosFormatter.format(newAllowance)}`
+ );
+}
+
+function resetDailyAllowance() {
+ this.dayTotalWithdrawals = 0;
+}
+
function reportBalance() {
console.log(
`Name: ${this._name}, balance: ${eurosFormatter.format(this._cash)}`
@@ -38,6 +54,8 @@ function createWallet(name, cash = 0) {
return {
_name: name,
_cash: cash,
+ dailyAllowance: 40,
+ dayTotalWithdrawals: 0,
deposit,
withdraw,
transferInto,
diff --git a/Week4/prep-exercises/1-wallet/ex5-prototype.js b/Week4/prep-exercises/1-wallet/ex5-prototype.js
index 7cba410..8057630 100644
--- a/Week4/prep-exercises/1-wallet/ex5-prototype.js
+++ b/Week4/prep-exercises/1-wallet/ex5-prototype.js
@@ -3,6 +3,8 @@ import eurosFormatter from './euroFormatter.js';
function Wallet(name, cash) {
this._name = name;
this._cash = cash;
+ this.dailyAllowance = 40;
+ this.dayTotalWithdrawals = 0;
}
Wallet.prototype.deposit = function (amount) {
@@ -14,8 +16,13 @@ Wallet.prototype.withdraw = function (amount) {
console.log(`Insufficient funds!`);
return 0;
}
+ if (this.dayTotalWithdrawals + amount > this.dailyAllowance) {
+ console.log(`Insufficient remaining daily allowance!`);
+ return 0;
+ }
this._cash -= amount;
+ this.dayTotalWithdrawals += amount;
return amount;
};
@@ -29,6 +36,17 @@ Wallet.prototype.transferInto = function (wallet, amount) {
wallet.deposit(withdrawnAmount);
};
+Wallet.prototype.setDailyAllowance = function (newAllowance) {
+ this.dailyAllowance = newAllowance;
+ console.log(
+ `Daily allowance set to: ${eurosFormatter.format(newAllowance)}`
+ );
+}
+
+Wallet.prototype.resetDailyAllowance = function () {
+ this.dailyAllowance = 0;
+}
+
Wallet.prototype.reportBalance = function () {
console.log(
`Name: ${this._name}, balance: ${eurosFormatter.format(this._cash)}`
diff --git a/hand-in-assignments-guide.md b/hand-in-assignments-guide.md
deleted file mode 100644
index cd4154f..0000000
--- a/hand-in-assignments-guide.md
+++ /dev/null
@@ -1,90 +0,0 @@
-# How to hand in the weekly assignment
-
-In this module you'll submit your assignment only using GIT and GitHub.
-
-1. [GitHub](https://www.github.com/HackYourFuture/JavaScript)
-
-## 1. GitHub Assignment Guide
-
-
-
-Watch the video (by clicking the image) or go through the following walk-through to learn how to submit your assignment:
-
-### 1.1 One Time Only (start of every module)
-
-1. Create a [fork](https://help.github.com/en/articles/fork-a-repo) of the assignment module repository. For JavaScript (as well as the next 2 modules), the assignment module repository is `https://www.github.com/HackYourAssignment/Assignment-cohortXX` where XX is your cohort number. You do this by using the `fork` option on the top right.
-2. Navigate to the URL of the cloned repository (it should be in your personal GitHub account, under "repositories").
-3. Clone the repository, using SSH[1], to your local machine. You can do this by typing in `git clone ` in the command line.
-4. On your local machine, navigate to the folder using the command line.
-5. Make sure you've cloned it correctly by running `git status` from the command line.
-6. This assignment repository is a little special, have a look through the README how it all works!
-
-### 1.2 Every Week
-
-1. First make sure that you are in your `main` branch. If not, check it out first.
-2. With your `main` branch checked out, create a new branch to work on the assignments of the new week. For example, for the assignment week 3[2] for JavaScript create a branch called `YOUR_NAME-w3-JavaScript`. Don't forget to checkout this branch after creating it. Note that you should never modify the `main` branch.
-3. Make your assignment!
-4. Once you're finished, add your assignment to a commit. There will be some test and config files added by the test runner, this is expected and should be added!
-5. Create the commit (`git commit`). Make the commit message meaningful, for example `Finished project for assignment week 3`.
-6. Push the branch to your forked repository.
-7. On the GitHub page of your forked repository, click on the `create pull request` button. Make sure the `base repository` is the `Assignment-cohortXX` repository, on branch `main`.
-8. Give the pull request a title in the same format as you used for the branch, e.g: `YOUR_NAME-w3-JavaScript`.
-9. Submit the pull request from your forked repository branch into the `main` branch of the destination repository.
-
-If you have any questions or if something is not entirely clear ¯\\\_(ツ)\_/¯, please ask/comment on Slack!
-
-**Notes:**
-
-
-[1] If you are in an AZC you may need to use HTTPS instead as the AZC may have blocked the network protocol used by SSH.
-[2] This first week for which you need to submit an assignment is week 2 of the JavaScript module.
-
-
-
-# Assignments Review Process
-
-## Before you start
-
-1. You get assigned a mentor at the start of the module in the slack group chat. (S)He is responsible for reviewing your work for the duration of the module.
-2. Please don't hesitate to contact your mentor or the education director if you are facing any issues. We are here to help you out!
-
-## Review process
-
-Together with the mentor and other trainees in your group you have the freedom to decide on the way of communication. You can do video calls or get feedback via comments to the PR.
-
-The mentor will start a group message on Slack and agree together on the way of communication. There, the mentor can keep the whole group informed of his/her availability and updates.
-
-### Video calls
-
-If your group chooses to do video calls, there're 2 options. Individual calls or a group call.
-
-Please write down some questions before te start of the call. During the call it is important to make notes of the feedback from the mentor, so you know what has to be adjusted afterwards.
-
-### Comments to the PR
-
-The mentor will place comments on your pull request. You have to adjust your work accordingly and reply on the feedback.
-
-### Timeline feedback
-
-| Days | Activities |
-| ------------------------------------- | ---------------------------------------------------------------------------------------- |
-| Tuesday (week 1) | Deadline for you to hand in your first version |
-| Wednesday (week 1) - Tuesday (week 2) | Mentor provides feedback |
-| Wednesday (week 2) - Tuesday (week 3) | you improve the assignment based on the feedback and mentor evaluates improvements |
-| Wednesday (week 3) | Core-team member Assignment Approval Check. At this point every PR needs to be approved. |
-
-It can happen that your mentor doesn't reply on your questions or your updated assignment. Please send a reminder via slack. If that doesn't work and you're afraid you can't make the deadline, contact your cohort supervisor.
-
-### Labels
-
-It is important for the you and the core-team to have up to date info about the status of the assignment. This is why the mentors use two labels on your PR.
-
-| Label | Description |
-| ---------- | ----------------------------------------------- |
-| no label | not reviewed yet |
-| Needs work | reviewed, but you need to implement feedback |
-| Approved | reviewed, and your assignment has been approved |
-
-Here is an example of this in action.
-
-