diff --git a/Lesson01-Git/newFile.js b/Lesson01-Git/newFile.js new file mode 100644 index 0000000..e69de29 diff --git a/Lesson02-HTML-CSS/homework/homework.html b/Lesson02-HTML-CSS/homework/homework.html index b722c6a..2cab0d2 100644 --- a/Lesson02-HTML-CSS/homework/homework.html +++ b/Lesson02-HTML-CSS/homework/homework.html @@ -1 +1,51 @@ - \ No newline at end of file + + + + Ezenagu's HTML homework + + + + +
+

Ezenagu Emmanuel

+

Lambda School

+

HTML/CSS homework

+
+ +
+ My favourite food is not just one, but the one I like most of them all is semovita with thick egwusi soup spiced with stock fish and beef. + My favourite restaurant +
+ +
+ +
+ + + + + + diff --git a/Lesson02-HTML-CSS/homework/styles.css b/Lesson02-HTML-CSS/homework/styles.css new file mode 100644 index 0000000..0ba3740 --- /dev/null +++ b/Lesson02-HTML-CSS/homework/styles.css @@ -0,0 +1,18 @@ + + #thirdDiv{ + height: 600px; + width: 500px; + background-color: hotpink; + padding: 50px; + border: 3px solid red; + } + #spanId{ + font-size: 18px; + marging: 50px; + } + h1{ + color: indigo; + } + img{ + width: 400px; + } diff --git a/Lesson03-CSS-Positioning/homework/homework.css b/Lesson03-CSS-Positioning/homework/homework.css index a45394a..09b7c6a 100644 --- a/Lesson03-CSS-Positioning/homework/homework.css +++ b/Lesson03-CSS-Positioning/homework/homework.css @@ -1,6 +1,6 @@ -/* -Lesson 3: CSS positioning homwork. All of your work should be done in this file. If you find yourself altering any of the other files -in this folder, you are in the wrong place. +/* +Lesson 3: CSS positioning homwork. All of your work should be done in this file. If you find yourself altering any of the other files +in this folder, you are in the wrong place. */ @@ -8,36 +8,69 @@ in this folder, you are in the wrong place. /* We will start this one off for you: */ #exerciseOne { - + display: block; + text-align: center; } /* Exercise Two: Positioning a Header Bar*/ /* Place code here */ - +#exerciseTwo{ + display: none; +} /* Exercise Three: */ /* Place code here */ - +#exerciseThree{ + position: relative; + top: 100px; + left: 200px; +} /* Exercise Four: */ /* Place code here */ +#exerciseFour{ + position: fixed; + top: 0; + left: 0; +} /* Exercise Five */ /* Place code here */ - +#exerciseFive{ + display: flex; + justify-content: space-around; + align-items: center; + flex-direction: row-reverse; +} /* Exercise Six */ #exerciseSeven { display: flex; + justify-content: space-between; + align-items: center; + flex-direction: row-reverse; + background-color: #ccc; +} +#itemFour{ + background-color: hotpink; +} +#itemThree{ + background-color: skyblue; +} +#itemTwo{ + background-color: goldenrod; +} +#itemOne{ + background-color: lime; } diff --git a/Lesson04-JS-I/homework/concept-Explained.txt b/Lesson04-JS-I/homework/concept-Explained.txt new file mode 100644 index 0000000..1a50368 --- /dev/null +++ b/Lesson04-JS-I/homework/concept-Explained.txt @@ -0,0 +1,17 @@ +Concepts Explained like a 12 year old. + +Variables: These are like a container or a bucket that can hold things. Those things are called values. + +Strings: This is a value that are like a word or a sentence in English language which can be stored in a variable. They have to be within '', "", or ``. + +Functions: These are like a phone you use to make calls. To talk to person A you just call the A call function and then you can speak to person A, +likewise if you want to speak to person B, call the B call function. This is so because functions can hold a set of tasks you will likely call often. + +(arguments): arguments are used with functions. they are used to pass values to functions to change the state or response of the function being called. + +(return): Functions return values. just like when you call, the phone returns to you the person you called or a switched off response or an unavailable +response. And since it returns values, the value(s) can be stored in a variable. + +if statements: These are used to answer Yes or No questions, like does A exist, if yes do this, or if No do not do this. + +Boolean values: These are also like Yes or No but they are values. either true or false diff --git a/Lesson04-JS-I/homework/homework.js b/Lesson04-JS-I/homework/homework.js index 0d3fc31..bab1c22 100644 --- a/Lesson04-JS-I/homework/homework.js +++ b/Lesson04-JS-I/homework/homework.js @@ -1,151 +1,200 @@ //In these first 6 questions, replace `null` with the answer //create a string variable, it can contain anything -const newString = null ; +const newString = 'Micheal Angelo' ; //create a number variable, it an be any number -const newNum = null ; +const newNum = 34 ; //create a boolean variable -const newBool = null ; +const newBool = true ; //solve the following math problem -const newSubtract = 10 - null === 5; +const newSubtract = 10 - 5 === 5; //Solve the following math problem -const newMultiply = 10 * null === 40 ; +const newMultiply = 10 * 4 === 40 ; //Solve the following math problem: -const newModulo = 21 % 5 === null ; +const newModulo = 21 % 5 === 1 ; -//In the next 22 problems you will compete the function. All of your code will go inside of the function braces. +//In the next 22 problems you will compete the function. All of your code will go inside of the function braces. //Make sure you use return when the prompt asks you to. -//hint: console.log() will NOT work. +//hint: console.log() will NOT work. //Do not change any of the function names function returnString(str) { //simply return the string provided: str + return str; } function add(x, y) { // x and y are numbers // add x and y together and return the value // code here + return x + y; } function subtract(x, y) { // subtract y from x and return the value // code here + return x - y; } function multiply(x, y) { // multiply x by y and return the value // code here + return x * y; } function divide(x, y) { // divide x by y and return the value // code here + return x / y; } function areEqual(x, y) { // return true if x and y are the same // otherwise return false // code here + if(x === y){ + return true; + } + return false; } function areSameLength(str1, str2) { // return true if the two strings have the same length // otherwise return false // code here + if(str1.length == str2.length){ + return true; + } + return false; } function lessThanNinety(num) { // return true if the function argument: num , is less than ninety // otherwise return false // code here + if(num < 90){ + return true; + } + return false; } function greaterThanFifty(num) { // return true if num is greater than fifty // otherwise return false // code here + if(num > 50){ + return true; + } + return false; } function getRemainder(x, y) { // return the remainder from dividing x by y // code here + let rem= x%y; + return rem; } function isEven(num) { // return true if num is even // otherwise return false // code here + let even= num % 2; + if(even == 0){ + return true; + } + return false; } function isOdd(num) { // return true if num is odd // otherwise return false // code here + // code here + let odd= num % 2; + if(odd == 1){ + return true; + } + return false; + } function square(num) { // square num and return the new value // hint: NOT square root! // code here + let square= Math.pow(num, 2); + return square; } function cube(num) { // cube num and return the new value // code here + + let cube= Math.pow(num, 3); + return cube; } function raiseToPower(num, exponent) { // raise num to whatever power is passed in as exponent // code here + Math.pow(num, exponent); } function roundNumber(num) { // round num and return it // code here + return Math.round(num); } function roundUp(num) { // round num up and return it // code here + return Math.ceil(num); } function addExclamationPoint(str) { // add an exclamation point to the end of str and return the new string // 'hello world' -> 'hello world!' // code here + return str + '!'; } function combineNames(firstName, lastName) { // return firstName and lastName combined as one string and separated by a space. // 'Lambda', 'School' -> 'Lambda School' // code here + return firstName + ' '+ lastName; } function getGreeting(name) { // Take the name string and concatenate other strings onto it so it takes the following form: // 'Sam' -> 'Hello Sam!' // code here + 'Hello '+ name +'!'; } -// The next three questions will have you implement math area formulas. +// The next three questions will have you implement math area formulas. // If you can't remember these area formulas then head over to Google. - + function getRectangleArea(length, width) { // return the area of the rectangle by using length and width // code here + return length * width; } function getTriangleArea(base, height) { // return the area of the triangle by using base and height // code here + let areaOfTriangle= base * height; + return areaOfTriangle/2; } // Do not modify code below this line. diff --git a/Lesson05-JS-II/homework/concept-Explanation.txt b/Lesson05-JS-II/homework/concept-Explanation.txt new file mode 100644 index 0000000..822d47e --- /dev/null +++ b/Lesson05-JS-II/homework/concept-Explanation.txt @@ -0,0 +1,11 @@ +Concepts Explained like to a 12 year old. + + +For: (For loop), this is a just a way to do something over again a certain number of times. Like texting to multiply people. Instead of texting one message to +everybody in your contact list you just need to loop through all the numbers you want to text to and send the message every time. + +&&: This is a way to check if two conditions are true. if the condition to the left is true and the one to the right is also true, it amounts to true. +if any one is false it amounts to false. + +||: This is a way to check if any one condition is true. if either of the condition to the left or to the right is true, it amounts to true. +if both conditions to the left and right is false it amounts to false. diff --git a/Lesson05-JS-II/homework/homework.js b/Lesson05-JS-II/homework/homework.js index 6f97f8d..2da7804 100644 --- a/Lesson05-JS-II/homework/homework.js +++ b/Lesson05-JS-II/homework/homework.js @@ -3,6 +3,13 @@ function getBiggest(x, y) { // x and y are integers. Return the larger integer // if they are the same return either one + if(x > y){ + return x; + }else if(x < y){ + return y; + }else{ + return x; + } } function greeting(language) { @@ -11,16 +18,33 @@ function greeting(language) { // language: 'Mandarin' -> 'Ni Hao!' // language: 'Spanish' -> 'Hola!' // if language is undefined return 'Hello!' + if(language == undefined){ + return 'Hello'; + }else if(language === 'German'){ + return 'Guten Tag!'; + }else if(language === 'Mandarin'){ + return 'Ni Hao!'; + }else if(language === 'Spanish'){ + return 'Hola'; + } } function isTenOrFive(num) { // return true if num is 10 or 5 // otherwise return false + if(num == 10 || num ==5){ + return true; + } + return false; } function isInRange(num) { // return true if num is less than 50 and greater than 20 // otherwise return false + if(num < 50 && num > 20){ + return true; + } + return false; } function isInteger(num) { @@ -30,6 +54,12 @@ function isInteger(num) { // -10 -> true // otherwise return false // hint: you can solve this using Math.floor + if(Math.floor(num) !== num){ + return false; + }else { + return true; + } + } function fizzBuzz(num) { @@ -37,6 +67,13 @@ function fizzBuzz(num) { // if num is divisible by 5 return 'buzz' // if num is divisible by 3 & 5 return 'fizzbuzz' // otherwise return num + if(num % 3 === 0){ + return 'fizz'; + }else if(num % 5 === 0){ + return 'buzz'; + }else if((num % 3 === 0) && (num % 5 === 0) ){ + return 'fizzbuzz'; + }return num; } function isPrime(num) { @@ -45,6 +82,24 @@ function isPrime(num) { // hint: a prime number is only evenly divisible by itself and 1 // hint2: you can solve this using a for loop // note: 0 and 1 are NOT considered prime numbers + if (num ===1) + { + return false; + } + else if(num === 2) + { + return true; + }else + { + for(var x = 2; x < num; x++) + { + if(num % x === 0) + { + return false; + } + } + return true; + } } diff --git a/Lesson06-JS-III/homework/concept-Explained.txt b/Lesson06-JS-III/homework/concept-Explained.txt new file mode 100644 index 0000000..05dacca --- /dev/null +++ b/Lesson06-JS-III/homework/concept-Explained.txt @@ -0,0 +1,6 @@ +Concepts Explained like to a 12 year old. + + +Arrays: This can be liken to a parking lot, In the parking lot cars are parked in the order. The parking lot has a name of parking lot and different kinds +of cars can park in the parking lot, so also it is with arrays. They are just like a container or the parking lot that can hold different types of data +which can be accessed individually using numbers called indexes. diff --git a/Lesson06-JS-III/homework/homework.js b/Lesson06-JS-III/homework/homework.js index dd99592..a15230e 100644 --- a/Lesson06-JS-III/homework/homework.js +++ b/Lesson06-JS-III/homework/homework.js @@ -2,31 +2,42 @@ function returnFirst(arr) { // return the first item from the array + return arr[0]; } function returnLast(arr) { // return the last item of the array + return arr[arr.length -1]; } function getArrayLength(arr) { // return the length of the array + return arr.length; } function incrementByOne(arr) { - // arr is an array of integers + // arr is an array of integers // increase each integer by one // return the array + for (let i = 0; i < arr.length; i++) { + arr[i]++; + } + return arr; } function addItemToArray(arr, item) { // add the item to the end of the array // return the array + arr.push(item); + return arr; } function addItemToFront(arr, item) { // add the item to the front of the array // return the array // hint: use the array method .unshift + arr.unshift(item); + return arr; } function wordsToSentence(words) { @@ -34,32 +45,75 @@ function wordsToSentence(words) { // return a string that is all of the words concatenated together // spaces need to be between each word // example: ['Hello', 'world!'] -> 'Hello world!' + let str=''; + for (let i=0; i < words.length; i++){ + str += words[i]; + str+= " "; + } + return str; } function contains(arr, item) { // check to see if item is inside of arr // return true if it is, otherwise return false + for(let i=0; i < arr.length; i++){ + if(arr[i] === item){ + return true; + } + } + return false; + } function addNumbers(numbers) { // numbers is an array of integers. // add all of the integers and return the value + let sum= 0; + for(let i=0; i < numbers.length; i++ ){ + sum += numbers[i]; + } + return sum; } function averageTestScore(testScores) { // testScores is an array. Iterate over testScores and compute the average. // return the average + let average= 0; + let totalTestScores = testScores.length; + for(let i=0; i < testScores.length; i++ ){ + average += testScores[i]; + } + return average/totalTestScores; } function largestNumber(numbers) { // numbers is an array of integers // return the largest integer + let largestNum=0; + for(let i=0; i < numbers.length-1; i++ ){ + if(numbers[i] > numbers[i + 1]){ + largestNum=numbers[i]; + } + return largestNum; + } } function multiplyArguments() { // use the arguments keyword to multiply all of the arguments together and return the product // if no arguments are passed in return 0 // if one argument is passed in just return it + let total = 1; + if(arguments.length === 0){ + return 0; + }else if(arguments.length === 1){ + return arguments[0]; + + }else{ + for (var i = 0; i < arguments.length; i++) { + total *= arguments[i]; + } + } + return total; } // Do not modify code below this line. diff --git a/Lesson07-JS-IV/homework/concepts-Explained.txt b/Lesson07-JS-IV/homework/concepts-Explained.txt new file mode 100644 index 0000000..d7caa40 --- /dev/null +++ b/Lesson07-JS-IV/homework/concepts-Explained.txt @@ -0,0 +1,9 @@ +Concepts Explained like to a 12 year old. + +Objects: Objects are like higher forms of variables, that shed or tell more details about what something or an idea can do through properties and Methods. +Properties: There are like the features or details of an object. They help us know more about an object. +Methods: They are like behaviors. They tell more about what an object can do. +For in loop: This is a method in javaScript that gives us an easy way to loop/go through all the keys in an object. +Dot Notation vs Bracket Notation: These both provide a way to access the individual properties or methods of an array. Dot notation uses a dot after +username and the particular property you want to access after the dot. Bracket notation uses the name of the object and then the particular property +inside quotes inside square brackets diff --git a/Lesson07-JS-IV/homework/homework.js b/Lesson07-JS-IV/homework/homework.js index 5fe8a01..5624776 100644 --- a/Lesson07-JS-IV/homework/homework.js +++ b/Lesson07-JS-IV/homework/homework.js @@ -5,61 +5,100 @@ function makeCat(name, age) { // add an age property to the object with the value set to the age argument // add a method called meow that returns the string 'Meow!' // return the object + let newObj = { + name: name, + age: age + } + return newObj; } function addProperty(object, property) { // add the property to the object with a value of null // return the object // note: the property name is NOT 'property'. The name is the value of the argument called property (a string) + object[property] = null; + return object; } function invokeMethod(object, method) { // method is a string that contains the name of a method on the object // invoke this method // nothing needs to be returned + let met = object[method]; + met(); } function multiplyMysteryNumberByFive(mysteryNumberObject) { // mysteryNumberObject has a property called mysteryNumber // multiply the mysteryNumber property by 5 and return the product + let result = mysteryNumberObject.mysteryNumber * 5; + return result; } function deleteProperty(object, property) { // remove the property from the object // return the object + delete object[property]; + return object; } function newUser(name, email, password) { // create a new object with properties matching the arguments passed in. // return the new object + let newObj = { + name: mane, + email: email, + password: password + } + return newObj; + } function hasEmail(user) { // return true if the user has a value for the property 'email' // otherwise return false + if(user.email == undefined){ + return false; + } + else if(user.email == null){ + return false; + } + return true; } function hasProperty(object, property) { // return true if the object has the value of the property argument // property is a string // otherwise return false + if(object === property){ + return true; + } + return false; } function verifyPassword(user, password) { // check to see if the provided password matches the password property on the user object // return true if they match // otherwise return false + if(user.password === password){ + return true; + } + return false; } function updatePassword(user, newPassword) { // replace the existing password on the user object with the value of newPassword // return the object + user.password = newPassword; + return user; } function addFriend(user, newFriend) { // user has a property called friends that is an array // add newFriend to the end of the friends array // return the user object + user.friends.push(newFriend); + return user; } function setUsersToPremium(users) { @@ -67,6 +106,9 @@ function setUsersToPremium(users) { // each user object has the property 'isPremium' // set each user's isPremium property to true // return the users array + for(let i=0; i < users.length; i++){ + users[i].isPremium = true; + } } function sumUserPostLikes(user) { @@ -75,6 +117,10 @@ function sumUserPostLikes(user) { // each post object has an integer property called 'likes' // sum together the likes from all the post objects // return the sum + let sum=0; + for(let i = 0; i < user.post.length; i++){ + sum += user.post[i].likes; + } } function addCalculateDiscountPriceMethod(storeItem) { @@ -82,10 +128,16 @@ function addCalculateDiscountPriceMethod(storeItem) { // this method should multiply the storeItem's 'price' and 'discountPercentage' to get the discount // the method then subtracts the discount from the price and returns the discounted price // return storeItem at the end of the function - // example: + // example: // price -> 20 // discountPercentage -> .2 // discountPrice = 20 - (20 * .2) + storeItem.calculateDiscountPrice = function(){ + let discount = this.price * this.discountPercentage; + discount = discount - this.price; + return discount; + } + return storeItem; } // Do not modify code below this line. diff --git a/Lesson08-JS-V/homework/concepts-Explained.txt b/Lesson08-JS-V/homework/concepts-Explained.txt new file mode 100644 index 0000000..ef1c89a --- /dev/null +++ b/Lesson08-JS-V/homework/concepts-Explained.txt @@ -0,0 +1,6 @@ +Concepts Explained like to a 12 year old. + +Prototype: This is just like a public container for classes where methods are stored so that every object created from the class need not have individual +methods but can call methods stored in the public container. + +Constructors: This helps you create objects out of classes. diff --git a/Lesson08-JS-V/homework/homework.js b/Lesson08-JS-V/homework/homework.js index e1447c7..b8fd165 100644 --- a/Lesson08-JS-V/homework/homework.js +++ b/Lesson08-JS-V/homework/homework.js @@ -7,11 +7,28 @@ function createUserClass() { // the constructor should have a method 'sayHi' on its prototype that returns the string 'Hello, my name is {{name}}' // {{name}} should be the name set on each instance // return the class + + function User(username, name, email, password){ + this.username: username; + this.name: name; + this.email: email; + this.password: password; + } + User.prototype.sayHi = function(){ + return "Hello, my name is "+ this.name; + } + + return User; } function addPrototypeMethod(Constructor) { // add a method to the constructor's prototype // the method should be called 'sayHi' and should return the string 'Hello World!' + + Constructor.prototype.sayHi = function(){ + return "Hello World!"; + } + } function addReverseString() { @@ -19,6 +36,14 @@ function addReverseString() { // name this method reverse // hint: // you will need to use 'this' inside of reverse + String.prototype.reverse = function(){ + let reverse = []; + for(let i = this.length-1; i > -1; i--){ + reverse.push(this[i]); + } + return reverse.join(); + } + } // Do not modify code below this line. diff --git a/Lesson09-JS-VI/homework/concepts-Explained.txt b/Lesson09-JS-VI/homework/concepts-Explained.txt new file mode 100644 index 0000000..a3f5d9d --- /dev/null +++ b/Lesson09-JS-VI/homework/concepts-Explained.txt @@ -0,0 +1,4 @@ +Concepts Explained like to a 12 year old. + + +Callbacks: These are functions that take another function in as an argument. It gets called inside the functions they are passed to. diff --git a/Lesson09-JS-VI/homework/homework.js b/Lesson09-JS-VI/homework/homework.js index 7aa3a77..43036c4 100644 --- a/Lesson09-JS-VI/homework/homework.js +++ b/Lesson09-JS-VI/homework/homework.js @@ -2,23 +2,37 @@ function invokeCallback(cb) { // invoke cb + cb(); } function sumArray(numbers, cb) { // sum up all of the integers in the numbers array // pass the result to cb // no return is necessary + let sum = 0; + for(let i=0; i < numbers.length; i++){ + sum += numbers[i]; + } + cb(sum); } function forEach(arr, cb) { // iterate over arr and pass its values to cb one by one // hint: you will be invoking cb multiple times (once for each value in the array) -} + for(let i=0; i < arr.length; i++){ + cb(arr[i]); + + } + } function map(arr, cb) { // create a new array // iterate over each value in arr, pass it to cb, then place the value returned from cb into the new arr // the new array should be the same length as the array argument + let nwArray = []; + for(let i=0; i < arr.length; i++){ + nwArray.push(cb(arr[i])); + } } // Do not modify code below this line. diff --git a/Lesson10-JS-VII/homework/concepts-Explained.txt b/Lesson10-JS-VII/homework/concepts-Explained.txt new file mode 100644 index 0000000..760c4c3 --- /dev/null +++ b/Lesson10-JS-VII/homework/concepts-Explained.txt @@ -0,0 +1,4 @@ +Concepts Explained like to a 12 year old. + +Closures: This is a concept that states that functions that are returned by the return statements of another function first has visibility of the +variables in the outer function before variables defined outside the functions. diff --git a/Lesson10-JS-VII/homework/homework.js b/Lesson10-JS-VII/homework/homework.js index e54a724..80eb34b 100644 --- a/Lesson10-JS-VII/homework/homework.js +++ b/Lesson10-JS-VII/homework/homework.js @@ -5,6 +5,11 @@ function counter() { // Example: const newCounter = counter(); // newCounter(); // 1 // newCounter(); // 2 + let counter=0; + return function(){ + counter++; + return counter; + } } function cacheFunction(cb) { @@ -18,6 +23,21 @@ function cacheFunction(cb) { // if the function you return is invoked with 5 it would pass 5 to cb(5) and return 25 // if the function you return is invoked again with 5 it will look on an object in the closure scope // and return 25 directly and will not invoke cb again + let safe={ + 'arg' : 0, + 'result': 0 + }; + return function(x){ + if(safe.arg == x){ + return safe.result; + }else{ + safe.arg = x; + safe.result = (x * x); + cb(x); + return (x * x); + } + } + } // Do not modify code below this line. diff --git a/Lesson11-JS-VIII/homework/concepts-Explained.txt b/Lesson11-JS-VIII/homework/concepts-Explained.txt new file mode 100644 index 0000000..5ccf671 --- /dev/null +++ b/Lesson11-JS-VIII/homework/concepts-Explained.txt @@ -0,0 +1,4 @@ +Concepts Explained like to a 12 year old. + +Recursion: This is just like going round and round and round in a loop. Function is being used to go in round in a loop. By making one function call +itself it creates a way a work in a loop. diff --git a/Lesson11-JS-VIII/homework/homework.js b/Lesson11-JS-VIII/homework/homework.js index 45fd2b1..bfeed51 100644 --- a/Lesson11-JS-VIII/homework/homework.js +++ b/Lesson11-JS-VIII/homework/homework.js @@ -6,11 +6,26 @@ function nFactorial(n) { // return the factorial for n // example: // the factorial of 3 is 6 (3 * 2 * 1) +if (n == 0) { + return 1; } + return n * nFactorial(n - 1); +} + function nFibonacci(n) { // fibonacci sequence: 1 2 3 5 8 13 ... // return the nth number in the sequence + let a = 1, b = 0, temp; + while (n >= 0){ + temp = a; + a = a + b; + b = temp; + n--; + } + + return b; + } // Do not modify code below this line.