From 0eb4b7f64cf06cb4365feaa7f279f66d3455163a Mon Sep 17 00:00:00 2001 From: BJORN-VINTHER Date: Wed, 5 Mar 2025 22:14:07 +0100 Subject: [PATCH 1/7] initial copy --- javascript1/week4/exercises/level0.md | 134 +++++++++++ javascript1/week4/exercises/level1.md | 314 ++++++++++++++++++++++++++ javascript1/week4/exercises/level2.md | 177 +++++++++++++++ javascript1/week4/exercises/level3.md | 67 ++++++ javascript1/week4/lesson.md | 107 +++++++++ 5 files changed, 799 insertions(+) create mode 100644 javascript1/week4/exercises/level0.md create mode 100644 javascript1/week4/exercises/level1.md create mode 100644 javascript1/week4/exercises/level2.md create mode 100644 javascript1/week4/exercises/level3.md create mode 100644 javascript1/week4/lesson.md diff --git a/javascript1/week4/exercises/level0.md b/javascript1/week4/exercises/level0.md new file mode 100644 index 00000000..f68c5d2d --- /dev/null +++ b/javascript1/week4/exercises/level0.md @@ -0,0 +1,134 @@ + + + + +# Warm-up Exercises +> [!IMPORTANT] +> These warm-up exercises are designed to ease you into the material. You don't need to complete all of them; instead, choose 1-2 sections that interest you and work on those. When you're ready for more challenging tasks, proceed to the [Level 1 exercises](./level1.md). + +[!TIP] +> **Divide and Conquer** is a programming technique that breaks a problem into smaller, more manageable subproblems, solves them individually, and then combines their solutions to solve the original problem. It is used to reduce problem complexity and making it easier to implement a solution and estimate the effort required. + +## πŸŽ“ 0.1 Running your Javascript +There are two main ways of running Javascript: Via the Browser or through the terminal using `node` +1. Create a `.js` file which logs: + * A regular log: `Hello World` + * A warning log: `Something is about to happen...` + * An error log: `KABOOOOM` +2. Run a script through the Browser + * Create a HTML file which include the javascript file + * Run the HTML file in the Browser + * Open the Developer Tools to see your logs +3. Run the script via Node + * Check if node is installed by running `node -v`. If it doesn't understand the command you have to [install Node](https://nodejs.org/en/download) + * Open the Terminal in VS Code + * Run the javascript file using the command `node `.
+ For instance `node ./script.js` + +## 🧱πŸ”₯ 0.2 Variables & Scope +1. Declare three variables: `name`, `age`, and `isStudent`. Assign appropriate values to them. +2. Can you help me fix my code? + ``` js + const name = "Alice"; + const age = 16; + const country = "USA"; + const message = ""; + const status = ""; + + if (age < 18) { + status = "minor"; + } else { + status = "adult"; + } + + message = `${name} is a ${status} from ${country}.`; + + console.log(message); // Alice is a minor from USA. + ``` +3. Why is my code not working? + ```js + const canSee = true; + if (canISee) { + let room = "This room is not dark"; + } + else { + room = "This room is pitch black"; + } + console.log(room); + ``` + + +## 🧱✨ 0.3 Data types +1. Define variables with different data types (string, number, boolean, undefined, null, object, array). They should all be something you may have for your team. + ```js + const team = "Team 31"; + // add more variables here... + ``` +2. Use `typeof` to check and print the type of each variable. +3. Guess the output, then run the code to see if you got it right. + ```js + const a = 10; + const b = -10; + const c = "100" + const d = "no"; + const e = true; + const f = false; + const g = null; + + console.log("#1", a + a, typeof (a + a)); // output is "#1 20 number" + + // guess the output of the following statements + console.log("#2", a + b, typeof (a + b)); + console.log("#3", a + c, typeof (a + c)); + console.log("#4", a + d, typeof (a + d)); + console.log("#5", a + e, typeof (a + e)); + console.log("#6", a + f, typeof (a + f)); + console.log("#7", a + g, typeof (a + g)); + ``` + + +## 🧱 0.4 Conditions +1. Write a function that takes a user’s age as input and prints whether they are a child (0-12), a teenager (13-19), or an adult (20+). +2. Create a function that asks for a number and prints whether it is positive, negative, or zero. +3. Write a function that checks if a given year is a leap year (Hint: A leap year is divisible by 4). + + + +## 🧱 0.5 Loops +1. Print numbers from 1 to 10 using a for loop. +2. Print a countdown from 10 to 1 using a for loop. +2. Print even numbers between 1 and 20 using a for loop. +4. Use a for...of loop to print each value in this array: + ```js + const names = ["john", "jane", "joe"]; + ``` + + +## 🧱 0.6 Arrays +1. Create an array of five favorite foods and print each item using a for..of loop. +1. Write a function that takes an array of numbers and returns the sum of all elements. What is the sum of `[5, 10, -98, 17.5, 365, -2.5]`? +1. Given an array `[10, 20, 30, 40, 50]`, write code to remove the last element and add 60 at the end. +1. Write a function that finds the largest number in an array + + + +## 🧱 0.7 Objects +1. Create an object representing a book with properties: `title`, `author`, and `yearPublished`. +2. Write a function that takes a book object and returns a string: `{title} by {author}, published in {yearPublished}`. +3. Add a method getAge to the book object that returns how old the book is based on the current year. +4. Write a function that takes an array of book objects and returns an array of all book titles. + + +## 🧱 0.8 Functions +1. Write a function `greet` that takes a name as a parameter and returns a greeting message + ```js + console.log(greet("Alice")); // "Hello, Alice!" + ``` +2. Write a function `add` that takes two numbers and returns their sum. + ```js + console.log(add(5, 3)); // 8 + ``` +3. Write a function `square` that returns the square of a number. Then, write another function `sumOfSquares` that takes two numbers and returns the sum of their squares. + ```js + console.log(sumOfSquares(3, 4)); // 25 (3Β² + 4Β² = 9 + 16) + ``` \ No newline at end of file diff --git a/javascript1/week4/exercises/level1.md b/javascript1/week4/exercises/level1.md new file mode 100644 index 00000000..1813361e --- /dev/null +++ b/javascript1/week4/exercises/level1.md @@ -0,0 +1,314 @@ + +# Level 1 - Regular Difficulty +> [!IMPORTANT] +> The Level 1 exercises will require you to apply your learnings from previous weeks. We recommend that you start with one exercise. If you find it easy, proceed to the [Level 2 exercises](./level2.md). Otherwise, try another exercise here. + + + + +## 🧱 1.1 Implement Student Grades +In this exercise you will create a basic system to manage student records. Let's get started: + +1. **Create Student Objects** + * Define a function `createStudent(name, age, grades)` that takes a student's name, age, and grades and return an object with these properties. +2. **Store Students in an Array** + * Create an empty array called `students`. + * Use the `createStudent` function to create at least three student objects and store them in the students array. +3. **Calculate Average Grade** + * Write a function `calculateAverageGrade(student)` that takes a student object and returns their average grade. +4. **Find the Best Student** + * Write a function `findTopStudent(students)` that takes an array of students and returns the student with the highest average grade. +5. **Display Student Information** + * Write a function `displayStudentInfo(student)` that logs a message like: + `"John, Age: 20, Average Grade: 85"` + * Use this function to display details for all students in the students array. +6. **Add Grades Dynamically** + * Modify the `createStudent` function to also include a method `addGrade(newGrade)` inside the student object, allowing new grades to be added dynamically. Use this function to add a grade to a student after it is created. + +Now help us answer these questions for the below students: + * What is the average grade of Frank? + * Who has the highest average grades? + * Who has the lowest average grades? + +> * Allan 20 years - Grades: [10, 10, 7, 4, 7] +> * Betty 22 years - Grades: [12, 7, 7, 4, 2] +> * Charlie 21 years - Grades: [10, 7, 4, 2, 0] +> * David 23 years - Grades: [7, 4, 2, 0, -3] +> * Eva 20 years - Grades: [12, 7, 10, 2, 12] +> * Grace 22 years - Grades: [7, 10, 7, 10, 7] +> * Henry 21 years - Grades: [4, 7, 7, 4, 4] +> * Irene 23 years - Grades: [2, 7, 7, 4, 0] + + + + + + + + + +## ✨ 1.2 Review IMDB's code +> [!TIP] +> When refactoring existing code there is always a risk that we introduce bugs, so it is crucial that you take precautions to reduce the risk of introducing bugs. Here are some good steps to follow which limits these risks: +> 1. **πŸ” Understand the Code**: Thoroughly read and understand the existing code. +> 2. **πŸ“ Plan Changes**: Outline the changes you intend to make and weigh the effort required against the benefits. +> 3. **πŸ§ͺ Create Test Scenarios**: Develop test scenarios and document their expected outcomes. +> 4. **πŸ’» Implement Changes**: Make the necessary code changes. +> 5. **βœ… Verify Functionality**: Ensure that your test scenarios still pass after the changes. + +1. Describe in your own words to a team mate or mentor what this code does +2. The code is hard to read due to poor naming. Can you improve it? (there might be more than just the names to improve) + + + +```js +function f(m) { + let a = []; + for (let i = 0; i < m.length; i++) { + if (m[i].rating >= 8) { + a.push(m[i].title); + }} return a; } + +let d = [ + { title: "Interstellar", rating: 8.6 }, + { title: "The Room", rating: 3.7 }, + { title: "The Godfather", rating: 9.2 }, + { title: "Cars", rating: 7.1 } +]; + +console.log(f(d)); +// Expected Output: ["Interstellar", "The Godfather"] +``` + + + + + + +## ✨ 1.3 Review the behaviour of JS +> [!TIP] +> When **reviewing** code now you want to watch out for: +> * Is all code required or can some be removed? +> * Are the naming of variables and functions good? +> * Is some code repeated which could be done with a function or a loop instead? +> * Are each function doing one thing really well? + +Your niece found this script on the internet and is asking how it works. +1. Guess the output +2. Now run the code, did you guess correctly? +```js +const a = 10; +const b = -10; +const c = "100" +const d = "no"; +const e = { + name: "John", +}; +const f = [1, 2, 3]; +const h = true; + +// guess the output of the following statements +console.log("#1", a + a); +console.log("#2", a + b); +console.log("#3", a + c); +console.log("#4", a + d); +console.log("#5", a + e); +console.log("#6", a + e["name"]); +console.log("#7", a + e["age"]); +console.log("#8", a + f); +console.log("#9", a + f[1]); +console.log("#10", a + h); +``` + + + +## πŸ”₯ 1.4 Troubleshoot issue with grades +> [!TIP] +> Effective troubleshooting involves a systematic approach: +> 1. **πŸ” Understand the Problem**: Gather all relevant information and understand how to reproduce the issue. +> 2. **πŸ•΅οΈ Identify the Issue**: Locate where in the code the problem occurs and determine its cause. +> 3. **πŸ”§ Develop a Solution**: Implement a fix for the issue. +> 4. **βœ… Test the Solution**: Ensure the problem is resolved and no new issues have been introduced. + +Below is a piece of code that is supposed to process a list of students and their grades, and return the average grade for the class. The calculation should ignore any invalid grades (negative numbers or non-numeric grades). However, the code has some bugs. Your task is to identify and fix the issues. + + + +```js +function calculateAverageGrade(students) { + let total = 0; + let count = 0; + + for (let i = 0; i < students.length; i++) { + let grade = students[i].grade; + + if (grade > 0) { + total += grade; + count++; + } else { + console.log("Invalid grade for student: " + students[i].name); + } + } + + return total / count; +} + +let studentsList = [ + { name: "Alice", grade: 90 }, + { name: "Bob", grade: -10 }, + { name: "Charlie", grade: 85 }, + { name: "David", grade: 100 }, + { name: "Eva", grade: "A" } +]; + +console.log("Average grade:", calculateAverageGrade(studentsList)); +// Expected Output: Average grade: 91.66 +``` + +**Tasks** +1. Identify the bug(s) in the code. +2. Fix the code so that it correctly calculates the average grade for the students. + + +## 🧱 1.5 Implement a Recipe Management System +You are tasked with creating a recipe management system. This system will keep track of recipes, each containing: +* The name of the recipe. +* The time it takes to cook the recipe, in minutes. +* A list of ingredients required for the recipe. + +``` +Spaghetti +30 min +spaghetti, tomato sauce, garlic + +Salad +10 min +lettuce, tomato, cucumber, olive oil + +Pancakes +20 min +flour, milk, eggs, sugar +``` + +**Tasks** +1. Create a list with the below recipes. Each recipes which each have a name, time, and ingredients. +2. Write a method to find the fastest recipe based on the cooking time. +3. Write another method to find all recipes that contain specific ingredients. The function should take an array of ingredients as an argument and return all recipes that contain any of those ingredients. + + + + + + +## ✨ 1.6 Review Amazon's code +1. Describe in your own words to a team mate or mentor what this code does +2. The code is hard to read due to poor naming. Can you improve it? (there might be more than just the names to improve) +```js +function filterItems(list) { + let result = []; + for (let i = 0; i < list.length; i++) { + if (list[i].price < 30 && list[i].inStock) { + if (list[i].price < 20) { + let item = list[i].item; + result.push(item); + } + } + } + if (result.length === 0) { + return []; + } + + return result; +} + +let shpitms = [ + { item: "Apple", price: 1.5, inStock: true }, + { item: "Laptop", price: 999.99, inStock: true }, + { item: "T-shirt", price: 15, inStock: false }, + { item: "Bananas", price: 2, inStock: true }, + { item: "Headphones", price: 25, inStock: true } +]; + +console.log(filterItems(shpitms)); +// Expected Output: ["Apple", "Bananas"] + +``` + + + +## πŸŽ“πŸ§± 1.7 Implement Graceful Error Handling +> [!TIP] +> The best way to verify your understanding of a topic or some code is to explain it to someone else! + +In this exercise, you will learn how to handle errors in JavaScript. Proper error handling is crucial for building robust applications. + + + +1. Learn how errors work in Javascript and explain it to a classmate and a mentor. + * How can I create a custom error? + * What does it mean to "handle" an error? + * What happens if you don't handle errors in your code? + * How can custom error classes improve error handling in your applications? + +1. **Basic Error Handling** + * Write a function `divide(a, b)` that returns the result of dividing `a` by `b`. + * What happens if you call divide(5, 0) + * Make sure the method logs a meaningful error: `Division by zero is not allowed` + +2. **Handling Multiple Errors** + * Use a `try...catch` block to handle errors that occurs. + ```js + function logOnlySmallNumbers(number) { + // make this function throw an error if the number is higher than 100 + // otherwise log the number + } + + function logSmallNumbers(numbers) { + // make sure this method logs all the small numbers by handling any errors + for (const number of numbers) { + logOnlySmallNumbers(number); + } + } + + logSmallNumbers([40, 150, 9999, 20, -10, 3000]); + ``` + + + + + + + + +## 🧱 1.8 Implement a Shopping Cart +You will create a basic shopping cart system that calculates the total price, applies discounts, and adds taxes. + +1. **Create a Visitor Object** + * Write a function createVisitor(name, age, height, hasPass) and returns an object with these properties. Height should be in cm. +2. **Calculate Ticket Price** + * Write a function calculateTicketPrice(visitor). + * Rules: + * Kids (under 12 years) β†’ $10 + * Teens (12-17 years) β†’ $15 + * Adults (18+) β†’ $20 + * Season Pass Holders β†’ Free! +3. **Ride Eligibility Check** 🎑 + * Write a function `canRide(visitor, minHeight)` that returns `true` if the visitor is tall enough, otherwise `false`. + * Example: + ```js + canRide({ name: "Alice", height: 140 }, 120); // true + canRide({ name: "Bob", height: 110 }, 120); // false + ``` + +4. **Group Visitors & Total Revenue** + * Create an array `visitors` with at least 5 visitor objects. + * Write a function `calculateTotalRevenue(visitors)` that: + * Loops through all visitors. + * Adds up the total ticket sales. + * Returns the total amount earned by the park. + +5. **Display Visitor Details** + * Write a function `displayVisitorInfo(visitor)` that logs: + ```yaml + Name: Jake | Age: 14 | Height: 150cm | Ticket Price: $15 + ``` diff --git a/javascript1/week4/exercises/level2.md b/javascript1/week4/exercises/level2.md new file mode 100644 index 00000000..d19af89b --- /dev/null +++ b/javascript1/week4/exercises/level2.md @@ -0,0 +1,177 @@ + +# Level 1 - Hard Difficulty +> [!IMPORTANT] +> These exercises will challenge all your skills so far. There will be less guidance compared to Level 1, and you may need to learn new topics independently. Choose an exercise that interests you. Once completed, if you seek an even greater challenge, proceed to the [Level 3 exercises](./level3.md). Otherwise, try another exercise here. + +> [!TIP] +> Remember to take **breaks** once in a while to stretch and rest your eyes. The most productive people take regular breaks. Here are some ideas: +> * Work for 25 minutes, then take a 5-minute break. +> * Work for 50 minutes, then take a 15-minute break. +> * Work in 90-minute deep focus sessions, then take a 20–30 minute break. + + +## πŸŽ“πŸ§± 2.1 Implement a Calendar +1. Learn how we can work with dates in Javascript and explain it to a classmate and a mentor. + * How can I get today's date? + * How can I get Jan 16th 1992? + * What kind of operations can I do with dates? +2. Write a function `daysUntilBirthday` that takes a birthdate (YYYY-MM-DD) as input and returns the number of days until the next birthday. + ```js + console.log(daysUntilBirthday("1995-06-15")); // Outputs the number of days until June 15 next occurrence + ``` +3. Write a function `ageOnDate` that takes a birthdate (YYYY-MM-DD) and a specific date (YYYY-MM-DD) as input and returns the age on that date. + ```js + console.log(ageOnDate("1995-06-15", "2025-06-15")); // Outputs 30 + ``` +4. Write a function `daysBetweenDates` that takes two dates (YYYY-MM-DD) as input and returns the number of days between them. + ```js + console.log(daysBetweenDates("2023-01-01", "2023-12-31")); // Outputs 364 + ``` + + + + + + + + + +## πŸŽ“βœ¨ 2.2 Review NASA's Code +> [!TIP] +> **Don't Repeat Yourself (DRY)** is a principle in software development that encourages avoiding code duplication by using functions, loops, or reusable components. This helps to keep the codebase clean, maintainable, and easier to understand. + +NASA has called you to review their code from the latest space mission. The current code works, but it’s inefficient. Identify repeated logic, unnecessary code, and ways to improve clarity. +1. The team member suggested that the code could be simplified using ternary operators, but what is that? + * Research what a ternary operator is and explain it to a team mate and a mentor +2. Note down the results of the existing code +3. Improve the code where possible: + * Is any code redundant and can be removed? + * Is any code repeated and can be reused in a function or loop instead? + * Are the variable names good? + * Can we use ternary operators anywhere? + * Anything else? +4. Verify that the code still works and gives the same results as in step 2. +```js +function getTicketPrice(age, isVIP) { + let price; + if (isVIP) { + price = 0; + } else { + if (age < 12) { + price = 50; + } else { + if (age >= 12 && age < 18) { + price = 75; + } else { + price = 100; + } + } + } + return price; +} + +function canTravel(height, age) { + if (height >= 140) { + if (age >= 10) { + return true; + } else { + return false; + } + } else { + return false; + } +} + +function printPassengerInfo(name, age, height, isVIP) { + let ticketPrice = getTicketPrice(age, isVIP); + let travelStatus = canTravel(height, age) ? "Approved for launch" : "Not eligible for space travel"; + console.log(name + " | Age: " + age + " | Height: " + height + "cm | Ticket Price: $" + ticketPrice + " | Travel Status: " + travelStatus); +} + +printPassengerInfo("John", 25, 180, false); +printPassengerInfo("Jane", 10, 130, false); +printPassengerInfo("Bob", 16, 155, true); +printPassengerInfo("Alice", 8, 120, false); +printPassengerInfo("David", 12, 140, false); +printPassengerInfo("Eve", 18, 160, false); +printPassengerInfo("Frank", 11, 145, false); +printPassengerInfo("Grace", 14, 135, false); +printPassengerInfo("Henry", 9, 125, false); +printPassengerInfo("Isabel", 13, 150, false); +printPassengerInfo("Kevin", 17, 170, false); +printPassengerInfo("Lucy", 7, 110, false); +printPassengerInfo("Michael", 15, 165, false); +printPassengerInfo("Nancy", 19, 175, false); +printPassengerInfo("Oliver", 6, 105, false); +printPassengerInfo("Patricia", 20, 185, false); +printPassengerInfo("Quinn", 5, 100, false); +printPassengerInfo("Robert", 21, 190, false); +``` + + + + + +## πŸ”₯🧱 2.3 Implement a Almost-Math tool +1. Write a function called `sumEvenNumbers` that takes an array of numbers and returns the sum of only the even numbers in the array. + ```js + sumEvenNumbers([1, 2, 3, 4, 5, 6]); + // Expected output: 12 (because 2 + 4 + 6 = 12) + + sumEvenNumbers([10, 15, 20, 25]); + // Expected output: 30 (because 10 + 20 = 30) + ``` +2. Write a function that takes an array of numbers and returns the second largest number. If there aren't enough unique numbers, return null. + ```js + console.log(secondLargest([10, 20, 4, 45, 99])); // 45 + console.log(secondLargest([3, 3, 3])); // null + console.log(secondLargest([5])); // null + console.log(secondLargest([])); // null + ``` +3. One of you team members added this function and went on vacation. Users have reported that they sometimes see a bug. Can you help find it? + * What do you think `doStuff()` is meant to do? + * Can you figure out why we get `NaN`? + ```js + function doStuff(numbers) { + const oddNumbers = []; + let sum = 0; + let count = 0; + for (let number of numbers) { + if (number % 2 !== 0) { + oddNumbers.push(number); + count = count + 1; + } + sum = 0; + } + for (let number of oddNumbers) { + sum += number; + } + + return sum / count; + } + + let numbers = [-3, 1, 8, 5, 7, 14, 98, 15]; + console.log(doStuff(numbers)); // Output: 5 + + numbers = [2, 4, 8, 5, 7]; + console.log(doStuff(numbers)); // Output: 6 + + numbers.pop(); + numbers.unshift(1); + numbers.pop(); + numbers.push(8); + numbers.unshift(2); + numbers[0] += 3; + numbers[2] *= 3; + console.log(doStuff([2, 4, 6])); // Nan??? + ``` +4. Write a function called `isPrime` that takes a number and returns true if the number is a prime number, otherwise false. It should support numbers 1-100 and otherwise throw an error. + ```js + console.log(isPrime(7)); // true + console.log(isPrime(10)); // false + ``` +5. Write a function called `factorial` that takes a number and returns its [factorial](https://www.mathsisfun.com/numbers/factorial.html). + ```js + console.log(factorial(5)); // 120 + console.log(factorial(7)); // 5040 + ``` diff --git a/javascript1/week4/exercises/level3.md b/javascript1/week4/exercises/level3.md new file mode 100644 index 00000000..55bddef1 --- /dev/null +++ b/javascript1/week4/exercises/level3.md @@ -0,0 +1,67 @@ + +# Level 3 - Very Hard Difficulty +> [!IMPORTANT] +> Welcome to the ultimate challenge! If you've made it this far, you're either very determined or looking for the toughest tasks. These exercises are not for the faint-hearted. There will be minimal guidance compared to the other levels, and you'll be working with more advanced topics. Choose an exercise that interests you, and don't hesitate to ask a mentor if you get stuck or revisit level 2 for a refresher. + + +## πŸŽ“πŸ§± 3.1 Implement a Guess-the-Number Game + +Let's create a small game where you have to guess a secret number between 1-100. + +1. We want to add some interactivity to our application. Investigate how our program can ask/prompt a user for an input and explain it to a classmate and a mentor: + * How can we get a simple input such as the name from the user? + * Is it the same way whether we run our JavaScript using an HTML page or Node.js? + +2. Write a program that prompts the user for their name and responds with: `Hello, !` + +3. Now create a simple number guessing game where: + * The program randomly selects a number between 1 and 100. + * The user must guess the number. + * The program provides feedback: + * "Too high!" if the guess is too high. + * "Too low!" if the guess is too low. + * "Congratulations! You guessed it!" if correct. + * The game continues until the user guesses correctly. + +4. Limit the number of guesses (e.g., 10 tries before revealing the answer). +5. Track the number of attempts and display it at the end. + + + +## πŸŽ“πŸ§± 3.2 Implement a Guess-the-Word Game (Wordle) +You need to create a simple [Wordle-like game](https://www.nytimes.com/games/wordle/index.html) using Node.js where: + +* The player has to guess a 5-letter word. +* They have 6 attempts to guess the correct word. +* After each guess, the game provides feedback in the form of colored text: + * Green for correct letters in the correct position. + * Yellow for correct letters in the wrong position. + * standard color for incorrect letters. +* If the player guesses the word correctly within 6 attempts, they win! +* If they run out of attempts, they lose and the correct word is revealed. + +1. make some code which selects a random secret word from these: + ```js + ["apple", "giant", "horse", "hacky", "steep"] + ``` +2. Write a function that takes a `secret word` and a `guess` and returns the colored response. For instance if the secret word is `apple` and you guess `alone` then the response should be A L `O` `N` E. +You can use the below code to write in color: + ```js + function green(text) { + return "\x1b[32m" + text + "\x1b[0m"; + } + + function yellow(text) { + return "\x1b[33m" + text + "\x1b[0m"; + } + + console.log(green('A'), yellow('L'), 'O', 'N', green('E')); + ``` +3. We want to add some interactivity to our application. Investigate how our program can ask/prompt a user for an input and explain it to a class mate and a mentor + * How can we get a simple input such as the name from the user? + * Is it the same way whether we run our Javascript using an html page or node? +4. Modify the code to prompt the user for input after each guess and log the colored response. +5. Implement the win/lose logic: + * If the player guesses the correct word within 6 attempts, log: `Congratulations, you guessed the right word in X tries.` (where X is the number of attempts). + * If the player uses all 6 guesses without success, log: `Sorry, you lose. The secret word was "APPLE".` + diff --git a/javascript1/week4/lesson.md b/javascript1/week4/lesson.md new file mode 100644 index 00000000..aa23da3b --- /dev/null +++ b/javascript1/week4/lesson.md @@ -0,0 +1,107 @@ + + + + +# `12:15` PART 1 - Soft Skills + +> [!IMPORTANT] +> Top 3 most important soft-skills to land your first job: +> * Problem-Solving +> * Communication & Collaboration +> * Continuous Learning & Adaptability + + +## Hard & Soft Skills +When you start applying for jobs, you will notice a significant focus on hard skills. However, this does not diminish the importance of soft skills. In Denmark, there is generally a greater emphasis on soft skills compared to many other countries. + +Also, as you become more senior there will be a higher demand for soft skills. + +#### Why Does Denmark Value Soft Skills Highly? +* Danish companies often have a flat structure, where developers are expected to take responsibility, communicate openly, and work closely with colleagues and managers. +* Many Danish tech companies follow Scrum and other agile methodologies, where teamwork and communication are key to success. +* Developers in Denmark are expected to take ownership of their tasks and actively participate in decision-making processes. +* Denmark has a strong consensus culture, meaning that decisions are often made through discussion and mutual agreement. This requires good communication skills, collaboration, and the ability to consider different perspectives. + +## Today's Exercises +The exercises for today are divided into four types to represent the types of tasks you will face in the industry and which skills they require. This is your first chance to really practice this, but you will develop and enhance these skills throughout your time at HYF, during your final project, and in your future career. +### 🧱 Implement New Code +> Skills needed: +> * Designing a solution +> * Breaking down the solution into manageable subtasks +> * Implementing the code +> * Testing to ensure it works as expected +> +> **Learning goal**: Be able to design, implement, and test a solution from scratch, ensuring it meets the requirements and functions correctly. + +### πŸ”₯ Troubleshoot issues +> Skills needed: +> * Understanding requirements +> * Reading and analyzing code +> * Identifying issues +> * Developing and testing solutions +> +> **Learning goal**: Efficiently identify and resolve errors in code without introducing new issues. + +### ✨ Review existing code +> Skills needed: +> * Understanding existing code +> * Identifying areas for improvement +> * Refactoring code and testing it +> +> **Learning goal**: Be able to read and understand code that does not follow your own coding style, identify potential improvements, and refactor it without introducing unintended side effects. + +### πŸŽ“ Learn new concepts and technologies +> Skills needed: +> * Researching and finding good information +> * Curiosity and willingness to explore +> * Hands-on experimentation +> * Explaining concepts to others +> +> **Learning goal**: Develop the ability to independently learn and understand new concepts and technologies, and effectively communicate your knowledge to others. + + + + +Now go to the [warm-up exercises](./exercises/level0.md) to get started! πŸ’ͺ + +Once you have completed a few tasks, feel free to challenge yourself with more difficult exercises: +* Our [Level 1 Exercises (regular)](./exercises/level1.md) will help you practice the topics already covered. +* Our [Level 2 Exercises (hard)](./exercises/level2.md) are for those who want a bit more challenge. These exercises are slightly harder and provide less guidance. +* Our [Level 3 Exercises (very hard)](./exercises/level3.md) are for those who want to push themselves further. These exercises are more difficult and may require you to learn new topics independently. + + + + + +# `13:45` PAUSE (30 min) + + + + + +# `14:15` PART 3 - Questions + +> [!IMPORTANT] +> What you should know about now: +> * Variables, Datatypes & Scopes +> * Operators +> * Arithmetic operators: `+`, `*` etc. +> * Conditional operators: `>=`, `!==` etc. +> * Arrays +> * Loops +> * Functions +> * Objects + + + + +# `14:30` PART 4 - More Exercises + +Continue working on the exercises... + + +# `15:50` Course Evaluation +* How are the exercises? +* How is the format? +* What worked well? +* What could work even better? \ No newline at end of file From 99b4d6e6af128629703215bd22431d895f9bee9d Mon Sep 17 00:00:00 2001 From: BJORN-VINTHER Date: Wed, 5 Mar 2025 22:46:02 +0100 Subject: [PATCH 2/7] tmp commit --- javascript1/week4/homework.md | 6 ------ javascript1/week4/lesson-plan.md | 18 +++++++++++----- javascript1/week4/preparation.md | 16 +++++++++++++++ javascript1/week4/readme.md | 35 +++++++++++++++++++++----------- 4 files changed, 52 insertions(+), 23 deletions(-) diff --git a/javascript1/week4/homework.md b/javascript1/week4/homework.md index 952a8790..209b3989 100644 --- a/javascript1/week4/homework.md +++ b/javascript1/week4/homework.md @@ -9,13 +9,7 @@ If you struggle to do this weeks homework there are a couple of things to do: - Watch the class recording. If it for some reason is missing. Then watch these: [part 1](https://www.youtube.com/watch?v=Mo54btMPN7Q), [part 2](https://www.youtube.com/watch?v=mSUAoual5sE), [part 3](https://www.youtube.com/watch?v=uq3NnTtXqsU) - Go through the last 3 weeks readme files. [Week 1](../week1/readme.md#variables), [week 2](../week2/readme.md#recap-logical-operators), [week 3](../week3/readme.md#objects) -## Finishing class exercises - -Finish the exercises from the class! - ## Codewars - - Complete these Katas in codewars:
- [7kyu Vowel Count](https://www.codewars.com/kata/54ff3102c1bad923760001f3)
- [7kyu Digit*Digit](https://www.codewars.com/kata/546e2562b03326a88e000020)
diff --git a/javascript1/week4/lesson-plan.md b/javascript1/week4/lesson-plan.md index 30a6bbba..cd492035 100644 --- a/javascript1/week4/lesson-plan.md +++ b/javascript1/week4/lesson-plan.md @@ -1,19 +1,27 @@ # Lesson plan ``` -> Focus on having lots of in class exercises. +> Focus on having lots of in-class exercises. Ideally, half the time should be used on exercises. -> DONT teach everything, let the students investigate topics on their own aswell! +> DON'T teach everything; let the trainees investigate topics on their own as well! -> Focus on how to read documentation, google answers and google errors!! +> Emphasize how to read documentation, search for answers, and debug errors! -> Teach towards the students being able to solve the homework +> Teach towards enabling trainees to solve the homework assignments. + +> Alternate between teaching and exercises. Avoid long lectures; most people can't focus for more than 45 minutes. ``` Remember to add the code you wrote in the class to the relevant class branch's class work folder. If the branch has not been created just create and push it :) If you dont have access, write to one from the core team. You can see an example below! To find examples of what teachers have taught before go to the class branches in the classwork folder, Fx [class 07](https://github.com/HackYourFuture-CPH/JavaScript/tree/class07/JavaScript1/Week1/classwork) -If you find anything that could be improved then please create a pull request! We welcome changes, so please get involved if you have any ideas!!! +> [!IMPORTANT] +> If you find anything that could be improved then please create a pull request! We welcome changes, so please get involved if you have any ideas! + +# Suggested Lesson Plan + +> [!TIP] +> Below is a suggestion for a lesson plan you can use. Feel free to use your own if it suits your better. Just make sure to cover [the learning goals](./readme.md). --- - Recap of js basics diff --git a/javascript1/week4/preparation.md b/javascript1/week4/preparation.md index ea08b1b4..913d28f5 100644 --- a/javascript1/week4/preparation.md +++ b/javascript1/week4/preparation.md @@ -6,4 +6,20 @@ Go through the learning goals of week 1, week 2 and week 3 of javascript. Make s - [Week 2 learning goals](../week2/readme.md) - [Week 3 learning goals](../week3/readme.md) +## Soft Skills of a Software Engineer +When you start applying for jobs, you will notice a significant focus on hard skills. However, this does not diminish the importance of soft skills. In Denmark, there is generally a greater emphasis on soft skills compared to many other countries. + +Some of the most important soft skills in the beginning of your career are: +> [!IMPORTANT] +> * Problem-Solving +> * Communication & Collaboration +> * Continuous Learning & Adaptability + + +#### Why Does Denmark Value Soft Skills Highly? +* Danish companies often have a flat structure, where developers are expected to take responsibility, communicate openly, and work closely with colleagues and managers. +* Many Danish tech companies follow Scrum and other agile methodologies, where teamwork and communication are key to success. +* Developers in Denmark are expected to take ownership of their tasks and actively participate in decision-making processes. +* Denmark has a strong consensus culture, meaning that decisions are often made through discussion and mutual agreement. This requires good communication skills, collaboration, and the ability to consider different perspectives. + _Please go through the material and come to class prepared!_ diff --git a/javascript1/week4/readme.md b/javascript1/week4/readme.md index cf2b66e8..363e6b9e 100644 --- a/javascript1/week4/readme.md +++ b/javascript1/week4/readme.md @@ -1,17 +1,28 @@ ## Learning goals -- [ ] Recap of js basics - - [ ] Variables - - [ ] Types - - [ ] Conditionals - - [ ] Functions - - [ ] For loop - - [ ] scope - - [ ] Arrays - - [ ] Objects -- [ ] Solving problems +For this session, we will reinforce the fundamental concepts of JavaScript covered in the past three weeks. You will gain extensive hands-on experience through various exercises. +#### JavaScript Basics +[Week 1](/javascript1/week1/readme.md): +- [ ] Variables +- [ ] Types +- [ ] Operators -## Relevant links +[Week 2](/javascript1/week2/readme.md): +- [ ] Conditionals +- [ ] Functions +- [ ] Scopes +- [ ] For loops + +[Week 3](/javascript1/week3/readme.md): +- [ ] Arrays +- [ ] Objects + +#### Essential Soft Skills for Junior Developers +- [ ] Problem-Solving +- [ ] Communication & Collaboration +- [ ] Continuous Learning & Adaptability + +## Relevant Links * [Preparation](preparation.md) * [Homework](homework.md) -* [Lesson plan](lesson-plan.md) +* [Lesson Plan](lesson-plan.md) From f7e0732a3f3a4da816fb92928d3d7213376f377f Mon Sep 17 00:00:00 2001 From: BJORN-VINTHER Date: Wed, 5 Mar 2025 23:42:33 +0100 Subject: [PATCH 3/7] tmp commit --- javascript1/week4/exercises/level0.md | 2 +- javascript1/week4/exercises/level1.md | 2 +- javascript1/week4/exercises/level2.md | 2 +- javascript1/week4/lesson-plan.md | 83 +++------------------ javascript1/week4/lesson.md | 100 +++++++------------------- javascript1/week4/preparation.md | 25 +++---- 6 files changed, 54 insertions(+), 160 deletions(-) diff --git a/javascript1/week4/exercises/level0.md b/javascript1/week4/exercises/level0.md index f68c5d2d..35ee9884 100644 --- a/javascript1/week4/exercises/level0.md +++ b/javascript1/week4/exercises/level0.md @@ -25,7 +25,7 @@ There are two main ways of running Javascript: Via the Browser or through the te * Run the javascript file using the command `node `.
For instance `node ./script.js` -## 🧱πŸ”₯ 0.2 Variables & Scope +## πŸ§±πŸ”Ž 0.2 Variables & Scope 1. Declare three variables: `name`, `age`, and `isStudent`. Assign appropriate values to them. 2. Can you help me fix my code? ``` js diff --git a/javascript1/week4/exercises/level1.md b/javascript1/week4/exercises/level1.md index 1813361e..da78d538 100644 --- a/javascript1/week4/exercises/level1.md +++ b/javascript1/week4/exercises/level1.md @@ -122,7 +122,7 @@ console.log("#10", a + h); -## πŸ”₯ 1.4 Troubleshoot issue with grades +## πŸ”Ž 1.4 Troubleshoot issue with grades > [!TIP] > Effective troubleshooting involves a systematic approach: > 1. **πŸ” Understand the Problem**: Gather all relevant information and understand how to reproduce the issue. diff --git a/javascript1/week4/exercises/level2.md b/javascript1/week4/exercises/level2.md index d19af89b..f905ce43 100644 --- a/javascript1/week4/exercises/level2.md +++ b/javascript1/week4/exercises/level2.md @@ -112,7 +112,7 @@ printPassengerInfo("Robert", 21, 190, false); -## πŸ”₯🧱 2.3 Implement a Almost-Math tool +## πŸ”ŽπŸ§± 2.3 Implement a Almost-Math tool 1. Write a function called `sumEvenNumbers` that takes an array of numbers and returns the sum of only the even numbers in the array. ```js sumEvenNumbers([1, 2, 3, 4, 5, 6]); diff --git a/javascript1/week4/lesson-plan.md b/javascript1/week4/lesson-plan.md index cd492035..4ae933c9 100644 --- a/javascript1/week4/lesson-plan.md +++ b/javascript1/week4/lesson-plan.md @@ -11,63 +11,25 @@ > Alternate between teaching and exercises. Avoid long lectures; most people can't focus for more than 45 minutes. ``` -Remember to add the code you wrote in the class to the relevant class branch's class work folder. If the branch has not been created just create and push it :) If you dont have access, write to one from the core team. You can see an example below! - -To find examples of what teachers have taught before go to the class branches in the classwork folder, Fx [class 07](https://github.com/HackYourFuture-CPH/JavaScript/tree/class07/JavaScript1/Week1/classwork) - -> [!IMPORTANT] -> If you find anything that could be improved then please create a pull request! We welcome changes, so please get involved if you have any ideas! - -# Suggested Lesson Plan - -> [!TIP] -> Below is a suggestion for a lesson plan you can use. Feel free to use your own if it suits your better. Just make sure to cover [the learning goals](./readme.md). - ---- -- Recap of js basics - - Variables - - Types - - Conditionals - - Functions - - For loop - - scope - - Arrays - - Objects - - Ask the students what they need to get repeated. Or figure it out by doing some code example. -- Solving problems - - https://dev.to/aprietof/5-steps-to-solving-programming-problems--502d -- [Code inspiration](#fibonacci-sequence) -- [Exercises](#exercises) - This class is about getting the basics hammered down. We have had a lot of students who think the js module is too difficult. That is why this class is here, too ease the steepness of the js learning curve. +``` Focus on -- Recapping what the students struggle with -- Letting the students learn a framework for solving problems -- Lots and lost of exercises πŸ’ͺ - -## Typical misconceptions - -- Difference between return and console.log -- What console.log does and what it is made for - -## Code inspiration - -### Fibonacci Sequence -Given a specific number in the fibonacci sequence return the fibonachi number. +> Recapping what the students struggle with +> Letting the students learn a framework for solving problems +> Lots and lost of exercises πŸ’ͺ +``` -```js -// 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 +> [!IMPORTANT] +> If you find anything that could be improved then please create a pull request! We welcome changes, so please get involved if you have any ideas! -fib(5) // 3 -fib(10) // 34 -``` +## Suggested Lesson Plan -Try not to just solve the problem, but explain what you are doing and thinking! +You can find a suggested lesson plan [here](./lesson.md). -Try using this as a framework for solving the problem: https://dev.to/aprietof/5-steps-to-solving-programming-problems--502d +Feel free to use your own lesson plan if it works better for your teaching style. Just ensure that you cover [the learning goals](./readme.md). -## Exercises +# Old material ### Fizz buzz @@ -79,29 +41,6 @@ When that works. Make the two number for multiples into parameters. So it can be `fizzBuzz(4, 12);` -### Build a sentiment analyzer - -A sentiment analyzer is some functionality that figures out how positive/negative a sentence is. - -Fx the sentence `I am mega super awesome happy" Should have a high score -The sentence "I hate doing boring stuff" should have a low score. - -Create a function that takes a string as a parameter. calling the function will return an object with `score`, `positiveWords` and `negativeWords`. You decide how the score should be implemented and what words are negative and positive. - -Here is an example of using the function: - -```js -const sentimentScoreObject = getSentimentScore('I am mega super awesome happy'); - -console.log(sentimentScoreObject); -/* -{ - score: 3, - positiveWords: ['happy', 'awesome', 'super'], - negativeWords: [], -} -*/ -``` ### Credit card number formatter diff --git a/javascript1/week4/lesson.md b/javascript1/week4/lesson.md index aa23da3b..6ba6a455 100644 --- a/javascript1/week4/lesson.md +++ b/javascript1/week4/lesson.md @@ -2,106 +2,60 @@ -# `12:15` PART 1 - Soft Skills +## `12:15` PART 1 - Soft Skills & Exercises > [!IMPORTANT] -> Top 3 most important soft-skills to land your first job: +> Top 3 most important soft skills to land your first job: > * Problem-Solving > * Communication & Collaboration > * Continuous Learning & Adaptability +### Today's Exercises -## Hard & Soft Skills -When you start applying for jobs, you will notice a significant focus on hard skills. However, this does not diminish the importance of soft skills. In Denmark, there is generally a greater emphasis on soft skills compared to many other countries. - -Also, as you become more senior there will be a higher demand for soft skills. - -#### Why Does Denmark Value Soft Skills Highly? -* Danish companies often have a flat structure, where developers are expected to take responsibility, communicate openly, and work closely with colleagues and managers. -* Many Danish tech companies follow Scrum and other agile methodologies, where teamwork and communication are key to success. -* Developers in Denmark are expected to take ownership of their tasks and actively participate in decision-making processes. -* Denmark has a strong consensus culture, meaning that decisions are often made through discussion and mutual agreement. This requires good communication skills, collaboration, and the ability to consider different perspectives. - -## Today's Exercises -The exercises for today are divided into four types to represent the types of tasks you will face in the industry and which skills they require. This is your first chance to really practice this, but you will develop and enhance these skills throughout your time at HYF, during your final project, and in your future career. -### 🧱 Implement New Code -> Skills needed: -> * Designing a solution -> * Breaking down the solution into manageable subtasks -> * Implementing the code -> * Testing to ensure it works as expected -> -> **Learning goal**: Be able to design, implement, and test a solution from scratch, ensuring it meets the requirements and functions correctly. - -### πŸ”₯ Troubleshoot issues -> Skills needed: -> * Understanding requirements -> * Reading and analyzing code -> * Identifying issues -> * Developing and testing solutions -> -> **Learning goal**: Efficiently identify and resolve errors in code without introducing new issues. - -### ✨ Review existing code -> Skills needed: -> * Understanding existing code -> * Identifying areas for improvement -> * Refactoring code and testing it -> -> **Learning goal**: Be able to read and understand code that does not follow your own coding style, identify potential improvements, and refactor it without introducing unintended side effects. - -### πŸŽ“ Learn new concepts and technologies -> Skills needed: -> * Researching and finding good information -> * Curiosity and willingness to explore -> * Hands-on experimentation -> * Explaining concepts to others -> -> **Learning goal**: Develop the ability to independently learn and understand new concepts and technologies, and effectively communicate your knowledge to others. +Goal for today: +* Solve 2 [warm-up exercises](./exercises/level0.md) to get started! πŸ’ͺ You decide which. +* Solve 3 [regular exercises](./exercises/level1.md). πŸ‘©β€πŸ’» You decide which. +* Solve 1 or more [hard exercises](./exercises/level2.md). πŸ₯‡ You decide which. +* **Bonus:** Solve 1 or more [very hard exercises](./exercises/level3.md). +### Types of Exercises + +Today's exercises are designed to simulate real-world tasks and develop essential skills: + +* 🧱 **Implement New Code** + * **Goal**: Design, implement, and test a solution from scratch, ensuring it meets requirements and functions correctly. +* πŸ”Ž **Troubleshoot Issues** + * **Goal**: Efficiently identify and resolve errors in code without introducing new issues. +* ✨ **Review Existing Code** + * **Goal**: Read and understand code that does not follow your own style, identify potential improvements, and refactor it without introducing unintended side effects. +* πŸŽ“ **Learn New Concepts and Technologies** + * **Goal**: Independently learn and understand new concepts and technologies, and effectively communicate your knowledge to others. -Now go to the [warm-up exercises](./exercises/level0.md) to get started! πŸ’ͺ -Once you have completed a few tasks, feel free to challenge yourself with more difficult exercises: -* Our [Level 1 Exercises (regular)](./exercises/level1.md) will help you practice the topics already covered. -* Our [Level 2 Exercises (hard)](./exercises/level2.md) are for those who want a bit more challenge. These exercises are slightly harder and provide less guidance. -* Our [Level 3 Exercises (very hard)](./exercises/level3.md) are for those who want to push themselves further. These exercises are more difficult and may require you to learn new topics independently. -# `13:45` PAUSE (30 min) +## `13:45` PAUSE (30 min) -# `14:15` PART 3 - Questions - -> [!IMPORTANT] -> What you should know about now: -> * Variables, Datatypes & Scopes -> * Operators -> * Arithmetic operators: `+`, `*` etc. -> * Conditional operators: `>=`, `!==` etc. -> * Arrays -> * Loops -> * Functions -> * Objects +## `14:15` PART 3 - Questions +Solve one regular exercise with class. -# `14:30` PART 4 - More Exercises +## `14:30` PART 4 - More Exercises Continue working on the exercises... -# `15:50` Course Evaluation -* How are the exercises? -* How is the format? -* What worked well? -* What could work even better? \ No newline at end of file +## `15:45` Introduction to home work +* Explain this weeks homework +* Give trainees a chance to ask any last questions about exercises or learning goals. diff --git a/javascript1/week4/preparation.md b/javascript1/week4/preparation.md index 913d28f5..c2c5aaf5 100644 --- a/javascript1/week4/preparation.md +++ b/javascript1/week4/preparation.md @@ -6,20 +6,21 @@ Go through the learning goals of week 1, week 2 and week 3 of javascript. Make s - [Week 2 learning goals](../week2/readme.md) - [Week 3 learning goals](../week3/readme.md) +_Please go through the material and come to class prepared!_ + ## Soft Skills of a Software Engineer -When you start applying for jobs, you will notice a significant focus on hard skills. However, this does not diminish the importance of soft skills. In Denmark, there is generally a greater emphasis on soft skills compared to many other countries. +When you start applying for jobs, you will notice a significant focus on hard skills. However, this does not diminish the importance of soft skills. In Denmark, there is generally a greater emphasis on soft skills compared to many other countries. -Some of the most important soft skills in the beginning of your career are: -> [!IMPORTANT] -> * Problem-Solving -> * Communication & Collaboration -> * Continuous Learning & Adaptability +### Important Soft Skills Early in Your Career +Some of the most important soft skills at the beginning of your career are: +- **Problem-Solving** +- **Communication & Collaboration** +- **Continuous Learning & Adaptability** +#### Why Denmark Values Soft Skills Highly +- **Flat Organizational Structures**: Danish companies often have a flat structure, where developers are expected to take responsibility, communicate openly, and work closely with colleagues and managers. +- **Agile Methodologies**: Many Danish tech companies follow Scrum and other agile methodologies, where teamwork and communication are key to success. +- **Ownership and Participation**: Developers in Denmark are expected to take ownership of their tasks and actively participate in decision-making processes. +- **Consensus Culture**: Denmark has a strong consensus culture, meaning that decisions are often made through discussion and mutual agreement. This requires good communication skills, collaboration, and the ability to consider different perspectives. -#### Why Does Denmark Value Soft Skills Highly? -* Danish companies often have a flat structure, where developers are expected to take responsibility, communicate openly, and work closely with colleagues and managers. -* Many Danish tech companies follow Scrum and other agile methodologies, where teamwork and communication are key to success. -* Developers in Denmark are expected to take ownership of their tasks and actively participate in decision-making processes. -* Denmark has a strong consensus culture, meaning that decisions are often made through discussion and mutual agreement. This requires good communication skills, collaboration, and the ability to consider different perspectives. -_Please go through the material and come to class prepared!_ From 7c67928c8bc16a945805ae0570f0f3c51541105b Mon Sep 17 00:00:00 2001 From: BJORN-VINTHER Date: Wed, 5 Mar 2025 23:45:38 +0100 Subject: [PATCH 4/7] removed tips --- javascript1/week4/exercises/level0.md | 3 --- javascript1/week4/exercises/level1.md | 22 ---------------------- javascript1/week4/exercises/level2.md | 10 ---------- 3 files changed, 35 deletions(-) diff --git a/javascript1/week4/exercises/level0.md b/javascript1/week4/exercises/level0.md index 35ee9884..c1e15266 100644 --- a/javascript1/week4/exercises/level0.md +++ b/javascript1/week4/exercises/level0.md @@ -6,9 +6,6 @@ > [!IMPORTANT] > These warm-up exercises are designed to ease you into the material. You don't need to complete all of them; instead, choose 1-2 sections that interest you and work on those. When you're ready for more challenging tasks, proceed to the [Level 1 exercises](./level1.md). -[!TIP] -> **Divide and Conquer** is a programming technique that breaks a problem into smaller, more manageable subproblems, solves them individually, and then combines their solutions to solve the original problem. It is used to reduce problem complexity and making it easier to implement a solution and estimate the effort required. - ## πŸŽ“ 0.1 Running your Javascript There are two main ways of running Javascript: Via the Browser or through the terminal using `node` 1. Create a `.js` file which logs: diff --git a/javascript1/week4/exercises/level1.md b/javascript1/week4/exercises/level1.md index da78d538..85a9ad22 100644 --- a/javascript1/week4/exercises/level1.md +++ b/javascript1/week4/exercises/level1.md @@ -48,14 +48,6 @@ Now help us answer these questions for the below students: ## ✨ 1.2 Review IMDB's code -> [!TIP] -> When refactoring existing code there is always a risk that we introduce bugs, so it is crucial that you take precautions to reduce the risk of introducing bugs. Here are some good steps to follow which limits these risks: -> 1. **πŸ” Understand the Code**: Thoroughly read and understand the existing code. -> 2. **πŸ“ Plan Changes**: Outline the changes you intend to make and weigh the effort required against the benefits. -> 3. **πŸ§ͺ Create Test Scenarios**: Develop test scenarios and document their expected outcomes. -> 4. **πŸ’» Implement Changes**: Make the necessary code changes. -> 5. **βœ… Verify Functionality**: Ensure that your test scenarios still pass after the changes. - 1. Describe in your own words to a team mate or mentor what this code does 2. The code is hard to read due to poor naming. Can you improve it? (there might be more than just the names to improve) @@ -86,13 +78,6 @@ console.log(f(d)); ## ✨ 1.3 Review the behaviour of JS -> [!TIP] -> When **reviewing** code now you want to watch out for: -> * Is all code required or can some be removed? -> * Are the naming of variables and functions good? -> * Is some code repeated which could be done with a function or a loop instead? -> * Are each function doing one thing really well? - Your niece found this script on the internet and is asking how it works. 1. Guess the output 2. Now run the code, did you guess correctly? @@ -123,13 +108,6 @@ console.log("#10", a + h); ## πŸ”Ž 1.4 Troubleshoot issue with grades -> [!TIP] -> Effective troubleshooting involves a systematic approach: -> 1. **πŸ” Understand the Problem**: Gather all relevant information and understand how to reproduce the issue. -> 2. **πŸ•΅οΈ Identify the Issue**: Locate where in the code the problem occurs and determine its cause. -> 3. **πŸ”§ Develop a Solution**: Implement a fix for the issue. -> 4. **βœ… Test the Solution**: Ensure the problem is resolved and no new issues have been introduced. - Below is a piece of code that is supposed to process a list of students and their grades, and return the average grade for the class. The calculation should ignore any invalid grades (negative numbers or non-numeric grades). However, the code has some bugs. Your task is to identify and fix the issues. diff --git a/javascript1/week4/exercises/level2.md b/javascript1/week4/exercises/level2.md index f905ce43..9fe6e728 100644 --- a/javascript1/week4/exercises/level2.md +++ b/javascript1/week4/exercises/level2.md @@ -3,13 +3,6 @@ > [!IMPORTANT] > These exercises will challenge all your skills so far. There will be less guidance compared to Level 1, and you may need to learn new topics independently. Choose an exercise that interests you. Once completed, if you seek an even greater challenge, proceed to the [Level 3 exercises](./level3.md). Otherwise, try another exercise here. -> [!TIP] -> Remember to take **breaks** once in a while to stretch and rest your eyes. The most productive people take regular breaks. Here are some ideas: -> * Work for 25 minutes, then take a 5-minute break. -> * Work for 50 minutes, then take a 15-minute break. -> * Work in 90-minute deep focus sessions, then take a 20–30 minute break. - - ## πŸŽ“πŸ§± 2.1 Implement a Calendar 1. Learn how we can work with dates in Javascript and explain it to a classmate and a mentor. * How can I get today's date? @@ -37,9 +30,6 @@ ## πŸŽ“βœ¨ 2.2 Review NASA's Code -> [!TIP] -> **Don't Repeat Yourself (DRY)** is a principle in software development that encourages avoiding code duplication by using functions, loops, or reusable components. This helps to keep the codebase clean, maintainable, and easier to understand. - NASA has called you to review their code from the latest space mission. The current code works, but it’s inefficient. Identify repeated logic, unnecessary code, and ways to improve clarity. 1. The team member suggested that the code could be simplified using ternary operators, but what is that? * Research what a ternary operator is and explain it to a team mate and a mentor From cedcf43c2ee656dfe1ea95f3205dd3dc8ea0b15d Mon Sep 17 00:00:00 2001 From: BJORN-VINTHER Date: Wed, 5 Mar 2025 23:50:34 +0100 Subject: [PATCH 5/7] Update readme.md --- javascript1/week4/readme.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/javascript1/week4/readme.md b/javascript1/week4/readme.md index 363e6b9e..a934169c 100644 --- a/javascript1/week4/readme.md +++ b/javascript1/week4/readme.md @@ -2,18 +2,13 @@ For this session, we will reinforce the fundamental concepts of JavaScript covered in the past three weeks. You will gain extensive hands-on experience through various exercises. #### JavaScript Basics -[Week 1](/javascript1/week1/readme.md): - [ ] Variables - [ ] Types - [ ] Operators - -[Week 2](/javascript1/week2/readme.md): - [ ] Conditionals - [ ] Functions - [ ] Scopes - [ ] For loops - -[Week 3](/javascript1/week3/readme.md): - [ ] Arrays - [ ] Objects From fc761d57aa7b72dfe712157d9436d9ac2a8e9959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Vinther?= Date: Sun, 16 Mar 2025 09:57:14 +0100 Subject: [PATCH 6/7] Update javascript1/week4/lesson-plan.md Co-authored-by: Marco Richetta --- javascript1/week4/lesson-plan.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript1/week4/lesson-plan.md b/javascript1/week4/lesson-plan.md index 4ae933c9..9b0ca6db 100644 --- a/javascript1/week4/lesson-plan.md +++ b/javascript1/week4/lesson-plan.md @@ -17,7 +17,7 @@ This class is about getting the basics hammered down. We have had a lot of stude Focus on > Recapping what the students struggle with > Letting the students learn a framework for solving problems -> Lots and lost of exercises πŸ’ͺ +> Lots and lots of exercises πŸ’ͺ ``` > [!IMPORTANT] From aecda2067391b92e45b253e7b78c49735dbf7f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Vinther?= Date: Sun, 16 Mar 2025 09:57:21 +0100 Subject: [PATCH 7/7] Update javascript1/week4/exercises/level2.md Co-authored-by: Marco Richetta --- javascript1/week4/exercises/level2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript1/week4/exercises/level2.md b/javascript1/week4/exercises/level2.md index 9fe6e728..8a27982c 100644 --- a/javascript1/week4/exercises/level2.md +++ b/javascript1/week4/exercises/level2.md @@ -102,7 +102,7 @@ printPassengerInfo("Robert", 21, 190, false); -## πŸ”ŽπŸ§± 2.3 Implement a Almost-Math tool +## πŸ”ŽπŸ§± 2.3 Implement an Almost-Math tool 1. Write a function called `sumEvenNumbers` that takes an array of numbers and returns the sum of only the even numbers in the array. ```js sumEvenNumbers([1, 2, 3, 4, 5, 6]);