From 1d09a4e05119ac509e6c4159f7b8ad539cf5d1d1 Mon Sep 17 00:00:00 2001 From: Katerina Date: Sun, 2 Jul 2023 21:58:21 +0200 Subject: [PATCH 1/3] Complete day 1 and 2 --- .vscode/settings.json | 3 +++ 01 - JavaScript Drum Kit/index-START.html | 18 +++++++++++++++++ 02 - JS and CSS Clock/index-START.html | 24 +++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..4f7b9b5c8f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "livePreview.defaultPreviewPath": "/02 - JS and CSS Clock/index-START.html" +} \ No newline at end of file diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 8a2f8e8417..ba45df208e 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -60,6 +60,24 @@ diff --git a/02 - JS and CSS Clock/index-START.html b/02 - JS and CSS Clock/index-START.html index 55ab1a5331..f62fbd2528 100644 --- a/02 - JS and CSS Clock/index-START.html +++ b/02 - JS and CSS Clock/index-START.html @@ -63,12 +63,36 @@ background: black; position: absolute; top: 50%; + transform-origin: 100%; /* rotate from right side oth the hand (middle)*/ + transform: rotate(90deg); /* set to 12 o'clock */ + transition: all 0.05s; + transition-timing-function: cubic-bezier(0.42, 1.81, 0.64, 1.97); } From 1d0ef170165a70bec90e74ac474921740a25b14b Mon Sep 17 00:00:00 2001 From: Katerina Date: Sun, 20 Aug 2023 16:25:53 +0200 Subject: [PATCH 2/3] Complete lessons 3-5 --- 03 - CSS Variables/index-START.html | 27 ++ 04 - Array Cardio Day 1/index-START.html | 2 +- 04 - Array Cardio Day 1/index.js | 59 +++++ 04 - Array Cardio Day 1/practice.js | 321 +++++++++++++++++++++++ 05 - Flex Panel Gallery/index-START.html | 34 ++- 5 files changed, 441 insertions(+), 2 deletions(-) create mode 100644 04 - Array Cardio Day 1/index.js create mode 100644 04 - Array Cardio Day 1/practice.js diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index d5fcc3a2ae..e9695444de 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -23,6 +23,22 @@

Update CSS Variables with JS

diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 0dcfd00f40..399d71c29b 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -38,7 +38,7 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's - + // Array.prototype.map() // 2. Give us an array of the inventors first and last names diff --git a/04 - Array Cardio Day 1/index.js b/04 - Array Cardio Day 1/index.js new file mode 100644 index 0000000000..5f9bc0538a --- /dev/null +++ b/04 - Array Cardio Day 1/index.js @@ -0,0 +1,59 @@ + +const inventors = [ + { first: 'Albert', last: 'Einstein', year: 1879, passed: 1955 }, + { first: 'Isaac', last: 'Newton', year: 1643, passed: 1727 }, + { first: 'Galileo', last: 'Galilei', year: 1564, passed: 1642 }, + { first: 'Marie', last: 'Curie', year: 1867, passed: 1934 }, + { first: 'Johannes', last: 'Kepler', year: 1571, passed: 1630 }, + { first: 'Nicolaus', last: 'Copernicus', year: 1473, passed: 1543 }, + { first: 'Max', last: 'Planck', year: 1858, passed: 1947 }, + { first: 'Katherine', last: 'Blodgett', year: 1898, passed: 1979 }, + { first: 'Ada', last: 'Lovelace', year: 1815, passed: 1852 }, + { first: 'Sarah E.', last: 'Goode', year: 1855, passed: 1905 }, + { first: 'Lise', last: 'Meitner', year: 1878, passed: 1968 }, + { first: 'Hanna', last: 'Hammarström', year: 1829, passed: 1909 } + ]; + + const people = [ + 'Bernhard, Sandra', 'Bethea, Erin', 'Becker, Carl', 'Bentsen, Lloyd', 'Beckett, Samuel', 'Blake, William', 'Berger, Ric', 'Beddoes, Mick', 'Beethoven, Ludwig', + 'Belloc, Hilaire', 'Begin, Menachem', 'Bellow, Saul', 'Benchley, Robert', 'Blair, Robert', 'Benenson, Peter', 'Benjamin, Walter', 'Berlin, Irving', + 'Benn, Tony', 'Benson, Leana', 'Bent, Silas', 'Berle, Milton', 'Berry, Halle', 'Biko, Steve', 'Beck, Glenn', 'Bergman, Ingmar', 'Black, Elk', 'Berio, Luciano', + 'Berne, Eric', 'Berra, Yogi', 'Berry, Wendell', 'Bevan, Aneurin', 'Ben-Gurion, David', 'Bevel, Ken', 'Biden, Joseph', 'Bennington, Chester', 'Bierce, Ambrose', + 'Billings, Josh', 'Birrell, Augustine', 'Blair, Tony', 'Beecher, Henry', 'Biondo, Frank' + ]; + + // Array.prototype.filter() + // 1. Filter the list of inventors for those who were born in the 1500's + const filteredInventors = inventors.filter(inventor => inventor.year > 1850) + // console.table(filteredInventors) + + + // Array.prototype.map() + // 2. Give us an array of the inventors first and last names + const fullNames = inventors.map(inventor => `${inventor.first} ${inventor.last}`) + console.table(fullNames) + + // Array.prototype.sort() + // 3. Sort the inventors by birthdate, oldest to youngest + + // Array.prototype.reduce() + // 4. How many years did all the inventors live all together? + + // 5. Sort the inventors by years lived + + // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name + // https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris + +const category = document.querySelector('.mw-category'); +const links = Array.from(category.querySelectorAll('a')); +const de = links + .map(link => link.textContent) + .filter(streetName => streetName.includes('de')); + + + // 7. sort Exercise + // Sort the people alphabetically by last name + + // 8. Reduce Exercise + // Sum up the instances of each of these + const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ]; \ No newline at end of file diff --git a/04 - Array Cardio Day 1/practice.js b/04 - Array Cardio Day 1/practice.js new file mode 100644 index 0000000000..a06b112b50 --- /dev/null +++ b/04 - Array Cardio Day 1/practice.js @@ -0,0 +1,321 @@ +const pattern = /account/gi; +const content = document.querySelector('#bodyContent'); +const ps = [...content.querySelectorAll('p')]; +const account = ps.map(word => word.textContent); +const accountStr = account.join(' '); +const accountMatch = accountStr.match(pattern); +const total = accountMatch.length + + +const etsy = document.querySelector('.responsive-listing-grid'); +const link = [...etsy.querySelectorAll('h3')]; +const jade = link.map(heading => heading.textContent).filter(stoneName => stoneName.includes('jade')); + + + +const arr1 = [1, 2, 3, 4]; +const reduced = arr1.reduce((total, current) => total + current); +// console.log(reduced); + +const arr2 = [1, 2, 3, 4]; +const reduced1 = arr2.reduce((total, current) => { + return total + current; +}, 2); +// console.log(reduced1) + +arr2.reverse(); +arr2.push(18); +const shiftted = arr2.shift(); +const shifted = [shiftted] +shifted.unshift("wow") +// console.log(shifted) +// console.log(arr2) + + +const arr = ["m", "a", "n", "d", "e", "e", "p"]; +// console.log(arr.join('*')); + + + +// -----------------------------------------------sort() + +// Sort an array of numbers in ascending order: +const numbers0 = [4, 2, 8, 5, 1, 3]; + +const sortNum = numbers0.sort((a, b) => a > b ? 1 : -1) +// console.log(sortNum) + +// Sort an array of strings in alphabetical order: +const fruits = ["banana", "apple", "cherry", "date"]; + +// console.log(fruits.sort()) +const reverseAlph = fruits.sort((a, b) => b > a ? 1 : -1) +// console.log(reverseAlph) + +const reverseAlph1 = fruits.sort((a, b) => b.localeCompare(a)) +// console.log(reverseAlph1) + +// Sort an array of objects based on a specific property: +const students22 = [ + { name: "Alice", age: 20 }, + { name: "Bob", age: 18 }, + { name: "Charlie", age: 22 } +]; + +const studentAge = students22.sort((a, b) => a.age > b.age ? 1 : -1) +// console.log(studentAge) + +const studentAge1 = students22.sort((a, b) => a.age - b.age) +// console.log(studentAge1) + +// Sort an array of strings in descending order: +const colors = ["red", "green", "blue", "yellow"]; + +const colorsBackwards = colors.sort((a, b) => b.localeCompare(a)) +// console.log(colorsBackwards) +const colorsBackwards1 = colors.sort((a, b) => b > a ? 1 : -1) +// console.log(colorsBackwards1) + +// Sort an array of objects alphabetically by a specific property: +const books22 = [ + { title: "JavaScript", author: "John" }, + { title: "Python", author: "Alice" }, + { title: "Java", author: "Bob" } +]; + +const bookTitleAlph = books22.sort((a,b) => a.title > b.title ? 1 : -1) +// console.log(bookTitleAlph) + +const bookAuth = books22.sort((a, b) => b.author.localeCompare(a.author)) +// console.log(bookAuth) + + +// ----map() +// Convert an array of numbers to their squared values: +const numbers22 = [1, 2, 3, 4, 5]; + +const squaredNum = numbers22.map(num => num * num) +// console.log(squaredNum) + +// Convert an array of names to uppercase: +const names = ["alice", "bob", "charlie"]; + +// console.log(names.map(n1 => n1.toUpperCase())) +const nameUpper = names.map(n => n.toUpperCase()) +// console.log(nameUpper) + + +// ----filter() +// Filter an array of numbers to get only the even numbers: +const numbers33 = [1, 2, 3, 4, 5,8, 20]; + +const evenNums = numbers33.filter(num => num % 2 == 0); +// console.log(evenNums) + +// Filter an array of objects based on a specific condition +const products22 = [ + { name: "Apple", price: 1.99 }, + { name: "Banana", price: 0.99 }, + { name: "Orange", price: 2.49 }, + { name: "Mango", price: 3.99 } +]; + +const productPrice = products22.filter(p => p.price > 2) +// console.log(productPrice) + + + + + +// -----------------------------------------------map() +// Task 1: +// Given an array of numbers, double each number in the array and return the new array. +const numbers1 = [1, 2, 3, 4, 5]; + +const doubled = numbers1.map(num => num * 2) +// console.log(doubled) + +function doubleNum(num) { + return num *2 +} +// console.log(numbers1.map(doubleNum)) + + +// Task 2: +// Given an array of strings, capitalize the first letter of each string and return the new array. +const strings1 = ['apple', 'banana', 'orange', 'kiwi']; + +const capita = strings1.map(str => str.charAt(0).toUpperCase() + str.slice(1)) +// console.log(capita) + +function capita1(str) { + return str.charAt(0).toUpperCase() + str.slice(1) +} +// console.log(strings1.map(capita1)) + + +// Task 3: +// Given an array of objects representing products, return an array of just the product names. +const products1 = [ + { id: 1, name: 'Product 1' }, + { id: 2, name: 'Product 2' }, + { id: 3, name: 'Product 3' }, +]; +const names10 = products1.map(product => product.name) +// console.log(names) + +// Task 4: +// Given an array of temperatures in Celsius, convert each temperature to Fahrenheit and +// return the new array. +const celsiusTemperatures = [20, 25, 30, 35, 40]; + +function fahrenheit(num) { + return num *1.8 + 32 +} +// console.log(celsiusTemperatures.map(fahrenheit)) + +const inFarenheit = celsiusTemperatures.map(temp => temp *1.8 + 32) +// console.log(inFarenheit) + + +// Task 5: +// Given an array of strings representing names, create an array of objects with a `name` +// property and a `length` property indicating the length of each name. +const names1 = ['John', 'Alice', 'Bob', 'Eve']; + +const smth1 = names1.map(function(n) { + return {name: n, length: n.length} +}) +// console.log(smth1) +const smth2 = names1.map(n => ({name: n, length: n.length})) +// console.log(smth2) + + +// -----------------------------------------------filter() +// Task 1: +// Given an array of numbers, filter out the numbers that are less than 10. +const numbers2 = [5, 12, 8, 20, 3, 15]; + +const less10 = numbers2.filter(num => num < 10) +// console.log(less10) + + +// Task 2: +// Given an array of objects representing books, +// filter out the books that were published before the year 2000. +const books2 = [ + { title: 'Book 1', year: 1995 }, + { title: 'Book 2', year: 2003 }, + { title: 'Book 3', year: 1998 }, +]; +const before2000 = books2.filter(book => book.year < 2000) +// console.table(before2000) + + +// Task 1: Filter an array of numbers to return only even numbers. +const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + +// (a) +const filterNum = numbers.filter(num => num % 2 === 0) +// console.log(filterNum) + +// (b) +function filterNums(num) { + return num % 2 === 0; +} + + const newNum = numbers.filter(filterNums) +// console.log(newNum) + + +// Task 2: Filter an array of strings to return only strings that have a length greater than 5. +const strings = ['apple', 'banana', 'orange', 'kiwi', 'strawberry']; + +const filterStr = strings.filter(str => str.length > 5) +// console.log(filterStr) + +function longerStr(str) { + return str.length > 5; +} +// console.log(strings.filter(longerStr)) + + +// Task 3: Filter an array of objects representing books, and return only books +// published in the last year. +const books = [ + { title: 'Book 1', year: 2020 }, + { title: 'Book 2', year: 2022 }, + { title: 'Book 3', year: 2022 }, + { title: 'Book 4', year: 2023 } +]; + +year = new Date().getFullYear(); + const filterBook = books.filter(book => book.year === year -1) +// console.log(filterBook) + + function lastYearPublish(book) { + return book.year === year - 1; + } + +// console.log(books.filter(lastYearPublish)) + + +// Task 4: Filter an array of objects representing students, +// and return only students who have a grade above 90. +const students = [ + { name: 'John', grade: 86 }, + { name: 'Alice', grade: 95 }, + { name: 'Bob', grade: 89 }, + { name: 'Eve', grade: 92 } +]; + +const highGrade = students.filter(student => student.grade > 85 && student.grade < 93) +// console.log(highGrade) + +function gradeHigh(student) { + return student.grade > 90 +} + +// console.log(students.filter(gradeHigh)) + +// Task 5: Filter an array of objects representing products, +// and return only products that are currently in stock. +const products = [ + { name: 'Product 1', inStock: true }, + { name: 'Product 2', inStock: false }, + { name: 'Product 3', inStock: true }, + { name: 'Product 4', inStock: false } +]; + +const productInStock = products.filter(product => !product.inStock) +// console.log(productInStock) + +function inStockProduct(product) { + return product.inStock +} +// console.log(products.filter(inStockProduct)) + + +// Task 6: Filter an array of objects representing employees, +// and return only employees who are full-time. +const employees = [ + { name: 'John', fullTime: true }, + { name: 'Alice', fullTime: false }, + { name: 'Bob', fullTime: true }, + { name: 'Eve', fullTime: true } +]; + +const fullTE = employees.filter(emp => emp.fullTime) +// console.log(fullTE) + +// Task 7: Filter an array of objects representing movies, +// and return only movies with a rating higher than 8. +const movies = [ + { title: 'Movie 1', rating: 7.5 }, + { title: 'Movie 2', rating: 8.2 }, + { title: 'Movie 3', rating: 9.1 }, + { title: 'Movie 4', rating: 7.8 } +]; + +const highRate = movies.filter(movie => movie.rating > 8.0) +// console.log(highRate) diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index 88a4f1d1e2..c3a641890b 100644 --- a/05 - Flex Panel Gallery/index-START.html +++ b/05 - Flex Panel Gallery/index-START.html @@ -27,6 +27,7 @@ .panels { min-height: 100vh; overflow: hidden; + display: flex; } .panel { @@ -44,6 +45,11 @@ font-size: 20px; background-size: cover; background-position: center; + flex: 1; + justify-content: center; + align-items: center; + display: flex; + flex-direction: column; } .panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); } @@ -56,9 +62,18 @@ .panel > * { margin: 0; width: 100%; - transition: transform 0.5s; + transition: transform 0.5s; + flex: 1 0 auto; + display: flex; + justify-content: center; + align-items: center; } + .panel > *:first-child { transform: translateY(-100%); } + .panel.open-active > *:first-child { transform: translateY(0); } + .panel > *:last-child { transform: translateY(100%); } + .panel.open-active > *:last-child { transform: translateY(0); } + .panel p { text-transform: uppercase; font-family: 'Amatic SC', cursive; @@ -71,6 +86,7 @@ } .panel.open { + flex: 5; font-size: 40px; } @@ -107,6 +123,22 @@ From f416d9c3775d84bdf10c68db567bddda8ef5fdd9 Mon Sep 17 00:00:00 2001 From: Katerina Date: Mon, 28 Aug 2023 16:07:59 +0200 Subject: [PATCH 3/3] lessons 6-8 --- .gitignore | 1 + 06 - Type Ahead/index-START.html | 41 ++++++++++++++ 07 - Array Cardio Day 2/index-START.html | 30 ++++++++++ 08 - Fun with HTML5 Canvas/index-START.html | 61 +++++++++++++++++++++ 4 files changed, 133 insertions(+) diff --git a/.gitignore b/.gitignore index 164ae8655c..132e3ba7c8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules/ *.log haters/ .idea/ +practice.js diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 5a9aa7e4e8..6c4571a7ad 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -18,6 +18,47 @@ diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 4ca34c7536..15e392d887 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -29,14 +29,44 @@ // Array.prototype.some() // is at least one person 19 or older? // Array.prototype.every() // is everyone 19 or older? + // const isAdult = people.some(function(person) { + // const currentYear = (new Date()).getFullYear(); + // if (currentYear - person.year >= 19) { + // return true; + // } + // }) + + const isAdult = people.some(person => (new Date()).getFullYear() - person.year >= 19); + const allAdult = people.every(person => (new Date()).getFullYear() - person.year >= 19); + + // console.log(isAdult) + // console.log(allAdult) + // Array.prototype.find() // Find is like filter, but instead returns just the one you are looking for // find the comment with the ID of 823423 + const comment = comments.find(comment => comment.id === 823423); + // console.log(comment) + // Array.prototype.findIndex() // Find the comment with this ID // delete the comment with the ID of 823423 + const index = comments.findIndex(comment => comment.id === 823423); + // console.log(index) + + // comments.splice(index, 1); + + const newComments = [ + ...comments.slice(0, index), + ...comments.slice(index + 1) + ] + + console.table(comments) + console.table(newComments) + + diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html index f70ad2059b..a3177cc8e0 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -8,6 +8,67 @@