Full Stack Camp
Open in Telegram
Fullstack Camp | Learn. Build. Launch. Join us for a hands-on journey through HTML, CSS, JavaScript, React, Node.js, Express & MongoDB â all in one place. Use this bot to search for lessons. @FullstackCamp_assistant_bot DM: @Tarikey6
Show moreThe country is not specifiedThe category is not specified
235
Subscribers
-124 hours
No data7 days
+330 days
Posts Archive
đ
Week 4 â Day 5 JavaScript OOP Basics:
Constructors, new, Prototypes, Inheritance & ES6 Classes
Hey hey, brilliant campers! đđ
Grab your â and settle inâtoday we level up from âusing objectsâ to designing them. By the end, youâll know how to build your own blueprints for data and behavior, share methods efficiently, and create families of related objects. This is the foundation of building real apps.
1) Why OOP? (Quick intuition)
Think of building many similar things:
â€A Student with name,grade,age, and methods like introduce() ,takeExam(), playFootball(),or getAverage().
â€A Product with price, discount logic, etc.
You donât want to copy-paste the same object structure again and again. You want a blueprint you can reuse to make many instances. Thatâs OOP.
Key words youâll see:
â
Class / Constructor â the blueprint
â
Instance â an object created from the blueprint
â
Method â a function that lives on the object
â
Prototype â where shared methods live (saves memory!)
â
Inheritance â one blueprint building on another
2) Constructor Functions (Preâclass style)
Before ES6 classes, JavaScript used constructor functions to act like blueprints. Now it's changed. But let's look what it was like since they are very related.
2.1 Defining a constructor
By convention, constructor names are Capitalized.
function Person(name, age) { this.name = name; // instance property this.age = age; // instance property // â Avoid defining methods here (explained below) }2.2 Creating instances with new
const p1 = new Person("Abebe", 20); const p2 = new Person("Saba", 22); console.log(p1.name); // "Abebe" console.log(p2.age); // 22ï»ż3) What does new actually do? When you write new Person("Abebe", 20) JavaScript does: â€Create a new empty object: {} â€Link that object to Person.prototype â€Bind this inside Person to the new object â€Return the object automatically If you forget new, this wonât point to a new objectâbugs ensue. 4) Prototypes: where shared methods live If you put methods inside the constructor, each instance gets its own copy (wasteful). Instead, attach methods to the prototype so all instances share one function.
function Person(name, age) { this.name = name; this.age = age; } // Shared by all Person instances Person.prototype.greet = function () { console.log(Hi, I'm ${this.name} and I'm ${this.age}.); }; const a = new Person("Almaz", 25); const b = new Person("Kebede", 30); a.greet(); // "Hi, I'm Almaz and I'm 25." b.greet(); // "Hi, I'm Kebede and I'm 30." console.log(a.greet === b.greet); // true â (one shared function)ï»ż 4.1 Property lookup (prototype chain) When you call a.greet(): â„JS looks for greet on a â„If not found, it looks on Person.prototype â„If still not found, it looks on Object.prototype â„âŠuntil it either finds it or gives undefined 5) Inheritance with Constructor Functions Letâs say a Student is a specialized Person. 5.1 Borrow the Person constructor for shared properties
function Student(name, age, major) { Person.call(this, name, age); // call Person with this instance this.major = major; }5.2 Link prototypes so methods are inherited
Student.prototype = Object.create(Person.prototype); // inherit Student.prototype.constructor = Student; // fix constructor pointer Student.prototype.study = function () { console.log(${this.name} is studying ${this.major}.); };5.3 Use it
const s = new Student("Mahi", 19, "Computer Science"); s.greet(); // from Person.prototype s.study(); // from Student.prototypeï»ż Thatâs classic JavaScript inheritance before classes.
đ„đ„ Week 4 Day 4 Challenges
Hey campers! đ Hope youâre all doing great and ready to flex your JavaScript muscles.
Todayâs challenges are all about objects and this, putting our new skills into action.
1ïžâŁ Student Grade Tracker
Create an object that stores student names and their scores.
â€Add a method to add a score.
â€Add a method to get the average score.
â€Add a method to find the highest scorer.
đĄ Hint: Store students in an array as objects like { name: "Abel", score: 89 }. Use loops to process the data.
2ïžâŁ Contact Book Lite
Make an object that stores peopleâs names and phone numbers.
â€Add a contact.
â€Delete a contact.
â€Show all contacts.
đĄ Hint: Use an array to store multiple contact objects. Example: { name: "Marta", phone: "0912345678" }.
3ïžâŁ Simple Shopping Cart
Build an object representing a shopping cart.
â€Add an item with name and price.
â€Remove an item by name.
â€Show the total price.
đĄ Hint: Items can be stored in an array as objects: { name: "Bread", price: 15 }. Loop through to get the total.
4ïžâŁ Movie Watchlist
An object that keeps a list of movies to watch.
â€Add a movie title.
â€Mark as watched.
â€Show all watched movies.
đĄ Hint: Each movie can be stored as { title: "Avatar", watched: false }. When marking as watched, update the property to true.
â
Your mission:
â¶ïžChoose any 3 challenges from todayâs list and bring them to life using objects and this.
After youâre done,
â
share your creations,
â
invite your friends to join our camp, and as always â
stay awesome and code on! âïž
Assignment
â€objects
https://youtu.be/lo7o91qLzxc?si=JNrFWZgMs-qn0AMW
â€this
https://youtu.be/Jdlo8ZDt5Jg?si=T3ahEgR7cbkW0pe9
Week 4 Day 4 JavaScript lesson
đ Hey there, my awesome campers!
Today, weâre diving into one of the most important building blocks in JavaScript:
â
Objects and
â
the mysterious keyword this.
By the end of today, youâll be able to make your code more organized, reusable, and real-world-ready.
1ïžâŁ What is an Object?
In JavaScript, objects are like containers for storing related data and functionality together in keyâvalue pairs.
Keys â the names (like labels).
Values â the actual data (can be strings, numbers, arrays, functions⊠even other objects!).
đŠ Analogy:
Think of an object like a basket with different compartments:
â€One holds injera (string value)
â€Another holds wot (number for quantity)
â€Another holds berbere (array for spice levels)
â€And another holds a cooking method (function).
Instead of carrying separate baskets for each thing, you keep them together in one basket â thatâs exactly how objects group related stuff.
Example:
let student = {
name: "Abebe",
age: 18,
skills: ["JavaScript", "HTML", "CSS"],
greet: function() {
console.log("Hello! My name is " + this.name); } };
console.log(student.name); // Access property: "Abebe"
console.log(student.skills[1]); // Access array inside object: "HTML"
student.greet(); // Call method: "Hello! My name is Abebe"
2ïžâŁ Creating Objects
We can create objects in two main ways:
1. Object literal (most common)
let car = {
brand: "Toyota",
year: 2020 };
2. Using the new Object() constructor (less common for beginners)
let car = new Object();
car.brand = "Toyota";
car.year = 2020;
3ïžâŁ Adding, Changing, and Removing Properties
let person = {
name: "Almaz",
age: 25 };
person.job = "Teacher"; // Add new property
person.age = 26; // Change value
delete person.name; // Remove property
console.log(person);
4ïžâŁ Methods (Functions inside Objects)
When a function lives inside an object, we call it a method.
let dog = {
name: "Bingo",
bark: function() {
console.log("Woof! Woof!"); } };
dog.bark(); // "Woof! Woof!"
ï»ż
5ïžâŁ The Special Keyword: this
What is this?
this is a special keyword that refers to the object that is currently using the method.
đŠ Analogy: Imagine each basket has its own âname tag.â When you say âthis basketâs injera,â you mean the injera inside the current basket youâre holding â not any other basket.
Example:
let user = {
name: "Sara",
greet: function() {
console.log("Hi, I'm " + this.name); } };
user.greet(); // "Hi, I'm Sara"
Here, this.name looks inside the object that called the method (in this case, user).
â ïž Important Note about this
If you use arrow functions inside objects, this behaves differently â it does not bind to the object, it takes this from the surrounding scope.
Example:
let user = {
name: "Kebede",
greet: () => { console.log("Hi, I'm " + this.name); } };
user.greet(); // "Hi, I'm undefined" đŹ
ï»ż
Why? Because arrow functions donât create their own this.
For methods, always use the regular function() syntax.
6ïžâŁ Real-World Example:
This is how objects + this help model real-world systems like banks, shops, games, etc. đ Summary: â Objects store related data and functions together. â Keys and values make objects flexible. â Methods are functions inside objects. â this refers to the object that owns the method. â Use function() for object methods (not arrow functions) if you need this.let bankAccount = { owner: "Mekdes", balance: 5000, deposit: function(amount) { this.balance += amount; console.log(${this.owner} deposited ${amount} birr. New balance: ${this.balance}); }, withdraw: function(amount) { if (amount <= this.balance) { this.balance -= amount; console.log(${this.owner} withdrew ${amount} birr. Remaining balance: ${this.balance}); } else { console.log("Insufficient funds!"); } } }; bankAccount.deposit(1000); bankAccount.withdraw(2000);
đ„Week 4 Day 3 Callback Challenges
1. Mood Tracker with Callback
What to do:
Ask the user for their mood for today, then use a callback function to display a custom message based on the mood they entered.
Hint:
Make one function to collect the mood, and another function (the callback) to decide what message to show.
Example moods: "happy", "sad", "mehh".
2. Custom Greeting Machine
What to do:
Write a function that takes a name and a callback. The callback will decide how to greet the person â formal, funny, or casual.
Hint:
Test it with three different callbacks to see how the same function can behave differently.
Example greetings: "Hello Mr. âŠ", "Yo âŠ", "Good day, âŠ".
3. Simple Math Processor
What to do:
Make a function that takes two numbers and a callback. The callback can decide to add, subtract, multiply, or divide them.
Hint:
Write four different callbacks for the four operations and try passing each one.
4. Random Joke Teller
What to do:
Make a function that picks a random joke from an array and pass it to another function (callback) that displays it in a special way â for example, uppercase, decorated, or with emojis.
Hint:
Use Math.floor(Math.random() * array.length) to pick a joke.
đŻ Your Mission Campers:
â€Pick any three of these challenges, solve them using what weâve learned, and push yourself to be creative with the callbacks.
â€When youâre done, share your work with the group,
†invite more friends to join the camp, and as alwaysâŠ
Stay curious, Stay coding andddd Stay well âïž
Week 4 Day 3 JavaScript Lesson:
đ Warm Greeting
"Hey my awesome campers! đ
Welcome back to our JavaScript jungle! đïž Today, weâre exploring a magical tool in our coderâs toolbox â something that lets our code talk to other code, hand over tasks, and say: 'Here, you handle this for me when youâre ready.'
Itâs called a callback function â and by the end of this lesson, youâll see why callbacks are one of the most important concepts in JavaScript. letâs go! đ¶ââïžđł
1. What is a Callback Function?
A callback function is simply:
A function that is passed as an argument to another function, and that other function can call it (or âinvokeâ it) later.In plain English: Think of callbacks like giving your friend a phone number before you go into a meeting. Youâre telling them:
âWhen you finish cooking, call me on this number so I know itâs ready.â đThey donât call you immediately â they call you when the cooking is done. Thatâs exactly how callbacks work. Basic Syntax
Here: greet is the callback. processUserInput is the function that receives the callback and calls it later. 2. Why Use Callbacks? We use callbacks when: â€We want to wait for something to finish (e.g., user input, data loading, timer, file download). â€We want code to be flexible (you can pass in different behavior without changing the original function). đĄ Think of callbacks as "fill in the blank" in a plan â the main function has the structure, and the callback decides the specific action. 3. Analogy â Ethiopian Coffee Ceremony â Imagine you are attending an Ethiopian coffee ceremony. You sit down and the host says: âTell me what snack you want, and Iâll bring it when the coffee is ready.â You give your snack choice â thatâs your callback. The host prepares coffee (main function), and when itâs ready, they call your function (bring your snack). 4. Synchronous vs Asynchronous Callbacks Synchronous callback Happens immediately during the function execution.function greet(name) { console.log(Hello, ${name}!); } function processUserInput(callback) { let name = prompt("Please enter your name:"); callback(name); // Call the function passed in } processUserInput(greet);
function sayHello() {
console.log("Hello!"); }
function runImmediately(callback) {
callback(); // Runs now }
runImmediately(sayHello);
console.log("This runs after sayHello");
Output:
Hello!
This runs after sayHello
Asynchronous callback
Happens later (after some time/event).
function showDone() {
console.log("Timer finished!"); }
console.log("Timer started..."); setTimeout(showDone, 2000); // Wait 2 seconds
Output:
Timer started...
(2 seconds later) Timer finished!
Here, setTimeout is like saying:
âWhen the timer finishes, call this function.â5. Callbacks with Parameters We can pass data into callbacks just like normal functions.
function printSquare(num) {
console.log(num * num); }
function doMath(num, callback) {
callback(num); }
doMath(5, printSquare); // Output: 25
6. Anonymous Callbacks
Instead of naming the callback, you can pass it directly as an anonymous function.
setTimeout(function () {
console.log("Anonymous callback says hi!"); }, 1000);
Or with arrow functions:
setTimeout(() => { console.log("Arrow function callback here!"); }, 1000);
â
Summary
â€A callback is a function passed into another function.
â€It can be synchronous or asynchronous.
â€Great for flexibility and waiting for tasks to finish.
â€Can be named, anonymous, or arrow functions.đ„đ„Week 4 Day 2 challenge
đ Hey
Weâve got some brain workouts lined up for you, but remember â these arenât just any exercises⊠theyâre real-world inspired coding adventures đ»âš
Here are 5 mini-quests â pick ANY 3 you like:
đ 1. Student Score Analyzer
Take an array of student scores and:
Increase every score by 5 (using map).
Keep only students who scored 50+ (using filter).
Find the average score (using reduce).
đĄ Hint: Each step can be chained or done separately â your call!
âïž 2. Word Counter
Ask the user for a sentence.
Count how many times each word appears â but store your counter in a closure so no one else can mess with it!
đĄ Hint: .split(" ") is your friend, and your closure will keep the count safe.
đą 3. Custom Multiplier
Create makeMultiplier(factor) that returns a function which multiplies any number by your factor.
Example:
let double = makeMultiplier(2); console.log(double(5)); // 10
đĄ Hint: That factor lives inside your closure â safe and sound.
đ 4. Activity Logger
Make a closure that keeps a private list of all activities you log (like âReadâ, âCodeâ, âRunâ).
Every time you call it, it adds the activity and shows how many youâve logged so far.
đĄ Hint: The activity list should live inside your function and never be exposed directly.
âïž 5. Even-Odd Divider
Given an array of numbers, separate them into even and odd arrays using filter().
Print both arrays at the end.
đĄ Hint: One filter call for evens, another for odds â short and clean!
đ„ Your Mission: Pick ANY 3 challenges. Tackle them with creativity.
Once done,
â¶ïžshare your solutions so we can all learn from each other,
â¶ïžinvite a friend to join the fun,
â¶ïžand as always â stay curious, stay coding, and stay well âïžAssignment
â€map
https://youtu.be/xNQH1NbZQ0E?si=bfCFeYqcmcFNo1hL
â€reduce
https://youtu.be/iDWtuWkuj8g?si=Jcry-t1EtJkIDTye
â€filter
https://youtu.be/VvSEKHKFvpQ?si=5W9FGrriVPTwWpX4
â€closure
https://youtu.be/beZfCfiuIkA?si=5weCkXWQ5df3ckCa
Classic counter example:
Even though createCounter() has finished running, the returned function still remembers count. That remembered state is the closure. Why closures are useful âȘïžPrivate state: emulate private variables (data hidden from the outside). âȘïžFactories: create configured functions (like makeMultiplier). âȘïžEvent handlers that remember context. âȘïžCallbacks that retain data over time. Private data example (bank account)function createCounter() { let count = 0; // variable in outer scope return function() { // inner function closes overcountcount += 1; return count; }; } const counter = createCounter(); console.log(counter()); // 1 console.log(counter()); // 2 console.log(counter()); // 3
Memory & closures â a word of caution Closures keep references to their outer variables, so those variables stay in memory until no function referencing them exists. Thatâs usually fine, but be careful: â€Donât accidentally keep very large data in a closure if not needed. â€Remove references when you no longer need them (set to null) if long-lived. More closure examples 1) Make specialized greeter (function factory)function createAccount(initial) { let balance = initial; // private return { deposit(amount) { if (amount > 0) balance += amount; return balance; }, withdraw(amount) { if (amount <= balance) balance -= amount; return balance; }, getBalance() { return balance; } }; } const account = createAccount(1000); account.deposit(200); // 1200 account.withdraw(100); // 1100 console.log(account.getBalance()); // 1100 // No direct access tobalancefrom outside â closure keeps it private.
ï»ż 2) Build a once-only function (run once memo)function makeGreeter(greeting) { return function(name) { console.log(${greeting}, ${name}!); }; } const saySelam = makeGreeter("Selam"); saySelam("Liya"); // Selam, Liya!
function once(fn) {
let done = false;
return function(...args) {
if (!done) {
done = true;
return fn(...args); } // otherwise do nothing }; }
const init = once(() => console.log("Initialized"));
init(); // prints init(); // nothing
3) Using closure with asynchronous callback
â Practical advice & patterns â€Use HOFs to move repeating logic out of loops. Example: abstract âloggingâ or âvalidationâ into functions you pass around. â€Use closures when you need private state or a factory that produces configured functions. â€Prefer let/const over var to avoid subtle closure/loop bugs. â€Donât overuse closures for huge data â be mindful of memory. â€Name functions clearly: makeAdder, filterAdults, sumAll â descriptive names help future-you.function delayedGreeter(name) { const message =Hello ${name}; setTimeout(() => { console.log(message); // closure keepsmessagealive until callback runs }, 1000); } delayedGreeter("Sami");
Week 4 Day 2 JavaScript Lesson:
đ Selam campers!
Lovely to see you back â hope your brains are rested and your fingers ready. Today weâre diving into two of the most important, beautiful, and practically useful ideas in JavaScript:
â
Higherâorder functions (functions that work with other functions)
â
Closures & lexical scope (how functions remember things)
These two topics are what make JavaScript so flexible and expressive.
đč PART 1 â HigherâOrder Functions (HOFs)
What is a higherâorder function?
A higherâorder function is simply a function that takes one or more functions as arguments, and/or returns a function. In other words â functions that treat other functions like data.
Think of it like cooking: a HOF is the recipe that accepts other little recipes (sauces) as ingredients, or spits out a new recipe you can use later.
Why HOFs matter
â€They let you reuse behavior (not just data).
â€They let you abstract patterns (e.g., âdo this to every itemâ).
â€They make code composable, readable, and concise.
Everyday HOFs you already use
âȘïžmap,
âȘïžfilter,
âȘïžreduce,
âȘïž forEach â these are HOFs built into arrays.
Example (map/filter/reduce quick look):
const nums = [1, 2, 3, 4, 5];
const doubled = nums.map(n => n * 2); // [2,4,6,8,10]
const evens = nums.filter(n => n % 2 === 0); // [2,4]
const sum = nums.reduce((acc, n) => acc + n, 0); // 15
Build-your-own HOF â a simple one
Suppose we want a function that applies any operation to every number:
function applyToEach(arr, fn) {
const result = [];
for (let i = 0; i < arr.length; i++) {
result.push(fn(arr[i])); // call the function passed in }
return result; }
const nums = [1, 4, 9];
const roots = applyToEach(nums, Math.sqrt); // [1,2,3]
applyToEach is a HOF because it takes a function (fn) and calls it.
HOF returning a function (function factories)
A HOF can return a function. This is useful for configurable behavior.
Example: a multiplier factory:
function makeMultiplier(factor) {
return function(n) { return n * factor; }; }
const double = makeMultiplier(2);
const triple = makeMultiplier(3);
console.log(double(5)); // 10
console.log(triple(5)); // 15
Here makeMultiplier returns different functions depending on the factor. Very handy!
Composition example (combine small functions)
We can make new functions by composing smaller functions.
const addOne = n => n + 1;
const square = n => n * n;
function compose(f, g) {
return function(x) {
return f(g(x)); }; }
const squareThenAddOne = compose(addOne, square);
console.log(squareThenAddOne(3)); //addOne(square(3)) = 10
Callbacks (synchronous and asynchronous)
A callback is simply a function passed to another function to be called later.
Synchronous callback:
Asynchronous callback example (youâll meet async later â this just demonstrates HOF usage over time):function greetUser(name, printer) { const message =Selam ${name}!; printer(message); // call the function passed in } greetUser("Liya", console.log);
setTimeout(() => console.log("Wake up!"), 1000); // callback fired later
đč PART 2 â Lexical Scope & Closures
â
What is lexical scope?
Lexical scope means a functionâs available variables are determined by where it was written in the source code, not where it is called.
Example:
function outer() {
let food = "injera"; // outer scope variable
function inner() {
console.log(food); // inner can see 'food' because of lexical scope }
inner(); }
outer(); // prints "injera"
The inner function sees food because food existed in the environment where inner was defined.
â
What is a closure?
A closure is when a function remembers the variables from its defining scope, even after that outer function has finished executing.đ„đ„Week4 day 1 Challenges:
đ Challenge 1: Super Combiner
Write a function that can take any number of arrays (not just two!)
Combine them into one single array
The result should have all the items together
đĄ Hints
Use rest parameters to grab all the arrays your function receives.
Then, use spread syntax to unpack them into one big array.
Test with fruit names, numbers, or even names of your classmates.
đ Challenge 2: Sentence Maker
You have a box of words â maybe theyâre proverbs from your grandmother or lyrics from your favorite Ethiopian song. Your job: turn them into a beautiful sentence.
Thatâs your challenge:
Write a function that takes an array of words
Return a string where the words are joined together with spaces
Bonus: allow extra words to be added separately (use rest parameters)
đĄ Hints
First, focus on joining the array words together.
Then, think: âWhat if I also had extra words I wanted to add?â
đŻ Your mission today:
â„Build both functions with your own creativity.
â„Test them with at least three different examples each.
â„Share your funniest or most creative results in the group.
â„Invite a friend to join our camp and most importantly
đ„ Keep the code flowing, keep the smiles glowing! âïž
Assignment:
â€spread operator
https://youtu.be/RuDdltsfaVc?si=C52S5F7eQuKYGnRZ
â€rest parameter
https://youtu.be/ahwR1D_GAfc?si=HQGuXPDC0H3KJldP
Week 4 Day 1 Js Lesson:
Hey, campersđ
I hope your fingers are feeling strong from all that typing and your brains are warmed up because today weâre officially stepping into Advanced JavaScript territory.
Youâve already met functions before, like old friends â but today, weâre going to dig deeper, learn their secrets, and make them work harder for us.
Weâll cover:
â
Function Declarations vs. Function â
Expressions
â
Arrow Functions in Depth
â
Default Parameters
â
Rest & Spread Parameters
1ïžâŁ Function Declarations vs. Function Expressions
In JavaScript, thereâs more than one way to create a function.
Function Declaration
This is the classic way â you just declare it, and JavaScript âhoistsâ it to the top of its scope, meaning you can call it even before itâs written in your code.
// Function Declaration
function sayHello() {
console.log("Hello, campers!"); }
sayHello(); // â
Works even if we call it before the function is defined
Key points:
â„Hoisted (can be used before they appear in code)
â„Good for situations where order in code doesnât matter
Function Expression
Here, we store the function inside a variable.
These are NOT hoisted, so you can only use them after they are defined.
// Function Expression
const sayHi = function() {
console.log("Hi, campers!"); };
sayHi(); // â
Works here
If we tried calling sayHi() before its definition â â error.
Why use them?
â„More flexible (can pass them around like normal variables)
â„Useful in callbacks and dynamic code
2ïžâŁ Arrow Functions â in Depth
Weâve met them before, but letâs explore their deeper behavior.
// Normal function
const add = function(a, b) {
return a + b; };
// Arrow function
const addArrow = (a, b) => a + b;
ï»ż
Differences:
â„Shorter Syntax â Good for quick, one-line functions.
â„this Behavior â Arrow functions donât have their own this.
Instead, they use the this from the surrounding scope.
Example:
const person = { name: "Meresa", normalFunc: function() {
console.log("Normal:", this.name); }, arrowFunc: () => {
console.log("Arrow:", this.name); } };
person.normalFunc();
// Normal: Meresa person.arrowFunc();
// Arrow: undefined (because arrow uses global this)
Best use for arrow functions:
â„Small callbacks
â„When you want to keep this from the surrounding scope
3ïžâŁ Default Parameters
Sometimes, you want your function to have a âbackup valueâ if no argument is given.
Why useful? â„Avoids undefined when arguments are missing â„Makes functions safer and easier to use 4ïžâŁ Rest & Spread Parameters Rest Parameters (...) When you donât know how many arguments will be passed, rest parameters collect them into an array.function greet(name = "Camper") { console.log(Hello, ${name}!); } greet("Abebe"); // Hello, Abebe! greet(); // Hello, Camper!
function sumAll(...numbers) {
let sum = 0;
for (let num of numbers) {
sum += num; }
console.log(sum); }
sumAll(1, 2, 3); // 6
sumAll(5, 10, 15, 20); // 50
ï»ż
Spread Operator (...)
Instead of collecting arguments, spread takes an array and spreads its values into separate arguments.
const nums = [1, 2, 3];
console.log(Math.max(...nums)); // 3
Uses of spread:
â„Copy arrays:
const arr1 = [1, 2, 3];
const arr2 = [...arr1];
â„Merge arrays:
const arr3 = [4, 5];
const merged = [...arr1, ...arr3]; // [1,2,3,4,5]
đĄ Summary of Todayâs Power-Ups:
â
Declarations vs. Expressions â know when to use each
â
Arrow functions â short & keep this
â
Default parameters â safer function calls
â
Rest & spread â handle many values with eleganceExtra Challenges: Real-World Flavor
đ Selam Coder Family!
Week 3 is coming to a close, and wow â youâve already learned variables, loops, conditions, arrays, functions, and more! Thatâs not beginner stuff anymore â itâs foundational JavaScript! đȘ
But guess what?
Coding is like a muscle đȘ â you build it by using it.
Thatâs why challenges matter. They connect theory to practice, and give you a taste of real-life problem solving.
So today, letâs dive into 5 practical and slightly spicy challenges. Weâre slowly introducing you to the harsh but exciting world of coding. đ„
â
Choose 4 challenges to work on today (but feel free to try the remaining one if you can!)
1ïžâŁ đ”ïž Word Blocker
đ§ What to do:
Ask the user to enter a sentence.
Check if it contains any bad words (e.g. "bad", "ugly", etc).
If yes, replace them with "***".
đĄ Hints:
Use .includes() to check if a word is in the sentence.
Use .replace() to block the bad word.
You can use .toLowerCase() to make checking easier.
2ïžâŁ đ Lucky Draw Picker
đ§ What to do:
Let the user enter names of participants (as an array).
Then randomly pick a winner and print it.
đĄ Hints:
Use .push() to collect names using prompt inside a loop.
Use Math.random() and Math.floor() to pick a random index.
3ïžâŁ đ Name Shuffler
đ§ What to do:
Ask the user to enter their full name.
Reverse the letters of first and last name separately.
Then print it out like a fun secret identity.
đĄ Hints:
Use .split(" ") to separate first and last names.
Use .split(""), .reverse(), .join("") for reversing.
4ïžâŁ đ§ Memory Word Game
đ§ What to do:
Ask the user to enter 8 words (stored in an array).
Then ask: "What was the 3rd word?"
Check if they remember correctly.
đĄ Hints:
Use a loop to collect words into an array.
Use array index to compare the original 3rd word with the answer.
5ïžâŁ â° Simple Alarm Clock (Simulation)
đ§ What to do:
Ask the user for a wake-up hour (e.g. 7).
Use a loop to count from 1 to that number.
At the final hour, print ââ° Wake up!â
đĄ Extra twist:
Add a for loop and an if to simulate "snoozing" if the user says ânot nowâ. đ
đĄ Hints:
Use for to count hours.
You can add prompt() inside the loop to ask "wake up now?"
đ€ž Bonus Tip:
â€â€Try combining the techniques you've learned:
â€â€Use functions to organize your code.
â€â€Use arrays for storing user input.
Use loops, if, prompt, return, etc.
đŹ Share your solutions in the group, help your friends, and invite others to join the adventure.
Weâre building something amazing together â even if weâre just 53 for now đ
Stay curious, share the love, invite others, and stay well âïž
#fullstacksummercamp #Week3 #Challenges #JSBootcamp #PracticeToGrow
Repost from Birhan Nega
Donât Let Questions Make You Feel Small
If you're new to coding and constantly feel like:
âWhy canât I solve this small bug?â
âIs it normal to forget things I just learned?â
âDo real developers know all this by heart?â
âAm I even growing at all?â
Hereâs my advice:
đ Don't mistake confusion for failure.
Even experienced developers:
- Forget syntax
- Google daily
- Ask teammates for help
Get stuck on âsimpleâ problems
The difference?
Theyâve learned to be calm in the unknownânot because they know everything, but because theyâve been there enough times.
So if youâre asking a lot of questions, feeling lost at times, or doubting yourself...
â
Thatâs not a sign youâre failing.
đ„ Thatâs a sign youâre learning.
đ Thatâs how growth feels before it shows results.
-Stick with it.
-Code messy.
-Break things.
-Google hard.
Ask again.
Finish one more day.
Thatâs how you build a future-proof career. keep showing up
Week 3 Day 8 JS Challenges
đ Hey awesome learners!
Now itâs your turn to apply what youâve learned with todayâs exciting challenges!
đŻ Pick any 3 challenges below and start solving!
đž 1. Budget Checker
đ Ask the user for their monthly budget and then let them enter their weekly expenses (4 times). At the end, tell them if they stayed within their budget or not.
đĄ Hints:
Use prompt() in a for loop
Store values in array (optional)
Add them up, compare with budget
đ¶ 2. Mobile Data Tracker
đ Let the user input how many days theyâve used mobile data and how much they used each day. Calculate total usage and warn them if theyâve passed 1000 MB.
đĄ Hints:
Use loop + prompt
Store in array or add directly
Return ââ ïž Limit Exceeded!â if too much
đ 3. Daily Mood Tracker
đ Ask user for their mood each day of the week (7 times). At the end, summarize how many âhappyâ, âsadâ or âmehâ days they had.
đĄ Hints:
Loop 7 times
Use if conditions
Count each type
đ 4. Password Strength Checker
đ Ask the user to enter a password and give feedback like:
Weak (too short)
Medium (okay length)
Strong (has symbols + capital letters)
đĄ Hints:
Use .length, includes(), maybe toUpperCase()
Example symbol check: password.includes("!")
Check if password has capital using .toUpperCase() !== password
â 5. Simple Quiz App
đ Create a 3-question quiz using prompt(). Give score at the end.
đĄ Hints:
Store questions in an array (optional)
Track correct answers
Return: âYou got X out of 3!â
đ«±đœâđ«Čđœ Pick 3 you like the most, build them in small steps, and donât forget:
đą Share what you built,
đš Invite your friends to join,
and as alwaysâŠ
Stay creative, stay curious, and stay well! âïžđ»
Assignment :
â€variable scope
https://youtu.be/KyqmbIkZGIo?si=DpOiz2ueQfrFBbJg
â€math.random
https://youtu.be/K2upGO5Bb48?si=1IGyBHU9BUYvsAxv
â€math objects
https://youtu.be/uy-1WNqecnI?si=5s3QFwe5WbHFhyNC
