From 74c198b269dfcd9a7f07d255aa4418430e555470 Mon Sep 17 00:00:00 2001 From: Daniel Bekenstein Date: Sun, 31 Mar 2024 14:22:12 -0400 Subject: [PATCH 01/12] Update index.html --- 01-Fundamentals-Part-1/starter/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01-Fundamentals-Part-1/starter/index.html b/01-Fundamentals-Part-1/starter/index.html index 59529c7923..e7b8691d5f 100755 --- a/01-Fundamentals-Part-1/starter/index.html +++ b/01-Fundamentals-Part-1/starter/index.html @@ -9,7 +9,7 @@ body { height: 100vh; display: flex; - align-items: center; + align-items: left; background: linear-gradient(to top left, #28b487, #7dd56f); } h1 { From ed1237e84faac775971b195b46d8318e7c04ce4e Mon Sep 17 00:00:00 2001 From: Daniel Bekenstein Date: Sun, 31 Mar 2024 14:35:26 -0400 Subject: [PATCH 02/12] First --- .DS_Store | Bin 0 -> 6148 bytes 01-Fundamentals-Part-1/.DS_Store | Bin 0 -> 6148 bytes 01-Fundamentals-Part-1/starter/index.html | 4 +++- 01-Fundamentals-Part-1/starter/script.js | 8 ++++++++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .DS_Store create mode 100644 01-Fundamentals-Part-1/.DS_Store create mode 100644 01-Fundamentals-Part-1/starter/script.js diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d95c3845a7c009c90c1f34b43f86f0293f98de61 GIT binary patch literal 6148 zcmeHK%}N6?5T4X(yA+`Z6}>HZZLuvXikGGSoW&JAsMKAy=;Ah!?$#bkVek4vzKGA` zOp=PFdhnpA%)sQEOlFeJmnA;{Alied2~Y)qGAd!g!Qum0-^c*1-3m0I33WJv_vY?45M(lActLhG~I6 zrItmD6L>=7OOt-^`!Z4T2Jm#)n2}#hVw*;YU(X*Hv#1<4`QV~t6uulwO($VkQIL~5k(4>RVBV#{y zWMN+@LXVDqSBHb}406c~Fay&J%$aJH&i}*D-~ZD|Tw?~9fq%t-C?5C+ZJd%lTW2Om vXRV8RjY>jsxxu#-H1tu7v2+x#qH00EO9rB6F*k@F6ut;(8n|Evew2Y%YPD45 literal 0 HcmV?d00001 diff --git a/01-Fundamentals-Part-1/.DS_Store b/01-Fundamentals-Part-1/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..7fc5a21e6ba6f68f8444a476d7b4b438b53380f3 GIT binary patch literal 6148 zcmeHKISv9b4733WBpOP}e1RWC2wuPkI6EXHj(#iN#nTuc1!$pz0yLJKNgPk2OtD^z zh)yrtiO5Jq25>{U+R!%JH*Z-dBMOA$jI-?IxIJz5>q9I1b-=iNIf1#7<0JpDw=EhK zpaN8Y3Qz$m@L>hAzz&8VK9|Q)0V?qO3fT9dzzu6+6X>4~4Bi3&dkDK>?!5%CSO8cP zn?OWh8dP9VHCqe~I^resYGM-@bkS@+G;h}IP}Fb7`Nh*kYamA|Kn0!^=*Dtn^?we3 z)Bit{xS|47;I9

JavaScript Fundamentals – Part 1

+ + diff --git a/01-Fundamentals-Part-1/starter/script.js b/01-Fundamentals-Part-1/starter/script.js new file mode 100644 index 0000000000..35829ef6b4 --- /dev/null +++ b/01-Fundamentals-Part-1/starter/script.js @@ -0,0 +1,8 @@ +let js = "amazing"; +//if (js === "amazing") alert("JavaScript is FUN!"); + +//40 + 8 + 23 - 10; +console.log(40 + 8 + 23 - 10); + +let firstName = "Dan"; +console.log(firstName); From 808c1caeb346941338d7e057af3c4968f824b7a0 Mon Sep 17 00:00:00 2001 From: Daniel Bekenstein Date: Sun, 31 Mar 2024 16:59:37 -0400 Subject: [PATCH 03/12] part 1 done --- 01-Fundamentals-Part-1/starter/script.js | 46 ++++++++++++++++++++++++ 02-Fundamentals-Part-2/starter/script.js | 1 + 2 files changed, 47 insertions(+) diff --git a/01-Fundamentals-Part-1/starter/script.js b/01-Fundamentals-Part-1/starter/script.js index 35829ef6b4..e052601467 100644 --- a/01-Fundamentals-Part-1/starter/script.js +++ b/01-Fundamentals-Part-1/starter/script.js @@ -1,3 +1,4 @@ +/* let js = "amazing"; //if (js === "amazing") alert("JavaScript is FUN!"); @@ -6,3 +7,48 @@ console.log(40 + 8 + 23 - 10); let firstName = "Dan"; console.log(firstName); + + +console.log(country); +console.log(continent); +console.log(population); + +let population = 350000000; +let country = "United States"; +let continent = "North America"; +let language = "English"; + +console.log(population / 2); +console.log(population + 1); +console.log(population > 6000000); +console.log(population < 33000000); +console.log( + country + + " is in " + + continent + + ", and its " + + population + + " people speak " + + language +); + + +const age = 12; +const isOldEnough = age >= 18; + +if (age >= 18) { + console.log(`Sarah can start driving licence!`); +} else { + const yearsLeft = 18 - age; + console.log(`Sarah is too young, wait another ${yearsLeft} years.`); +} + +let century; +const birthYear = 1994; +if (birthYear <= 2000) { + century = 20; +} else { + century = 21; +} +console.log(century); +*/ diff --git a/02-Fundamentals-Part-2/starter/script.js b/02-Fundamentals-Part-2/starter/script.js index e69de29bb2..552ae55b93 100755 --- a/02-Fundamentals-Part-2/starter/script.js +++ b/02-Fundamentals-Part-2/starter/script.js @@ -0,0 +1 @@ +"user strict"; From 5bc90c825149fa07f32927f8570fed2803ad74b2 Mon Sep 17 00:00:00 2001 From: Daniel Bekenstein Date: Sun, 31 Mar 2024 18:45:08 -0400 Subject: [PATCH 04/12] Update script.js --- 02-Fundamentals-Part-2/starter/script.js | 37 +++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/02-Fundamentals-Part-2/starter/script.js b/02-Fundamentals-Part-2/starter/script.js index 552ae55b93..4319e6dabe 100755 --- a/02-Fundamentals-Part-2/starter/script.js +++ b/02-Fundamentals-Part-2/starter/script.js @@ -1 +1,36 @@ -"user strict"; +"use strict"; +/* +function logger(myName) { + console.log(`My name is ${myName}`); +} + +logger("Dan"); +logger("Bob"); + +function fruitProcessor(apples, oranges) { + console.log(apples, oranges); + const juice = `Juice with ${apples} apples and ${oranges} oranges.`; + return juice; +} + +console.log(fruitProcessor(5, 1)); + +const calcAge3 = (birthYear) => 2037 - birthYear; +console.log(calcAge3(1994)); +*/ +const calcAverage = (scr1, scr2, scr3) => (scr1 + scr2 + scr3) / 3; + +let scoreDolphins = calcAverage(44, 23, 71); +let scoreKoalas = calcAverage(65, 54, 49); + +function checkWinner(avgDolphins, avgKoalas) { + if (avgKoalas > avgDolphins * 2) { + console.log(`Koalas win (${avgKoalas} vs. ${avgDolphins})`); + } else if (avgDolphins > avgKoalas * 2) { + console.log(`Koalas win (${avgDolphins} vs. ${avgKoalas})`); + } else { + console.log(`No team wins...`); + } +} + +checkWinner(scoreDolphins, scoreKoalas); From 9f49c19f5c2efac83a8bfcdf7abd62cf3499647d Mon Sep 17 00:00:00 2001 From: Daniel Bekenstein Date: Tue, 2 Apr 2024 21:05:12 -0400 Subject: [PATCH 05/12] Loops --- .DS_Store | Bin 6148 -> 8196 bytes 02-Fundamentals-Part-2/starter/script.js | 120 ++++++++++++++++++++++- 2 files changed, 119 insertions(+), 1 deletion(-) diff --git a/.DS_Store b/.DS_Store index d95c3845a7c009c90c1f34b43f86f0293f98de61..b1d95ce13be644ee985f7202e7fbe0352be5da95 100644 GIT binary patch literal 8196 zcmeHMU2GLa6h3EL=DL+eFT)0{+MOwUV_%DXrKS}{D;kNXL!gcT66*g>l%iX=V zAgMOd#2-|Q`edRHsPO?K@xcV2d@!g{6OC#7N!0lFqKS!#8sn3m+1X2^&_sMtV|S97 zGjqg0Km?I*$Pk#05Vlh*&=GLQMjDftBMqH%84TB0~Ejo6ATy!>#Er? zBlbY-f!G7F2VxJz9{4YKfbMKwtrA&uME1F;9@r3d)=kf6$GDx%YZhDQfAVG2N$ zrvPE0KIH+SP9mbIh)xR{s?sw>_JENpMkxjgb&@CebfT$)W zCmh=klF5%yDl1>Gu%be#SX6O1eaxFo2S!lvJB|DyJ{s^mCtKU;U1E1WoNlP>3F7%TYJ0gDvuqSZ}mK11c@#mnngH#D`hZQ0S$v*(VP%BpIns!Nv* z6>Z-J^q(wiz57C3m`keV1+J6{QA82V7&^nyIX=V%iF=PG$}Aa3O1- zDA>U%@hnYWrO52nF_RX&-7~qS8A>!wze$!4aei0cqE@g~t#K_W7y~}-Ioi(pW<_EC zz;SxFLRC$+$_g_F9V2Tw5o^w{vUxb?jgQm5eZkgtrevADeT1*Q z&+vo(3Crcnb1QVMTb4(-q{B3c$*QX=clB!8sDI4JTm6%SH};_{hy1<758n_;_;Y$p zJMi+6us;+s+b!AzW_p(b)3Pi#q?!bxLgzK4l47LL6;=lu=)&3!WAp)R0#3mr@EDwh zXW>P-0I$L8@D98S@4@>p1E0ee@Fjc&-@{MvGyDR-VmVe~6;|U)T!S}bBQ{|RZpJOR z6}RI~+>L#>2lwFtJcMI-7&CYjC-4O3v4HpB1Nb05glF(+d=8(-7w`gJ#5eE~zKL() z2lzF9gWuv05=baXQkk?^s*&o&rlnGl42f~6l~z*kx()^klIUQNj$A89^qyV4|5A{A zx|oMW&61_dmapQmvT6Iy%ZL&fEWz&2a1IfC1@1!xhcA6L^t2VVb@l2E`XE8vIypP& zO2Nn~IGE)bK6|x#qs|sk5QyO#wNYmaDFDQ9oxWaY62+YuZqSn|E2F4VLS02)ugapk zS>39#a*8f7Y*%kn8SuasE^#33BPQOu!<7P=v3eGG64@5O1n5AVlE z@hm=$PvDdI6h4FJ@cb-f_LVRxD86*P$SkJwuH(5!Nw0+VD<3&eM`gn9TAu&+%>Dg; zo_Z%XJNCf*@Bo%~r@K4J*11kco@*zl-bs}gK5tskP=y*kh4aI7oap6045^=pWT}Ww d3rZ3y|M-W1`2OcV`TxSN*7*Jp0s22}{s70zH_8A2 delta 152 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{MGjUEV6q~50$jG!YU^nAr0~wad%!0a;Z3MU( zcTV;YDCCf=uGTd)vM`%`KtP_cd-4My*)vJdVDo!13C4{L` 2037 - birthYear; console.log(calcAge3(1994)); -*/ + const calcAverage = (scr1, scr2, scr3) => (scr1 + scr2 + scr3) / 3; let scoreDolphins = calcAverage(44, 23, 71); @@ -34,3 +34,121 @@ function checkWinner(avgDolphins, avgKoalas) { } checkWinner(scoreDolphins, scoreKoalas); +*/ + +/* +const friends = ["Michael", "Steven", "Peter"]; +console.log(friends); + +console.log(friends[0]); +console.log(friends[2]); + +console.log(friends.length); +console.log(friends[friends.length - 1]); + +friends[2] = "Jay"; +console.log(friends); + +const dan = ["Dan", "Bekenstein", 2024 - 1994, "Product Manager", friends]; +console.log(dan); +console.log(dan.length); + +const calcAge = function (birthYear) { + return 2037 - birthYear; +}; +const years = [1990, 1967, 2002, 2010, 2018]; + +const age1 = calcAge(years[0]); +const age2 = calcAge(years[1]); +const age3 = calcAge(years[years.length - 1]); +console.log(age1, age2, age3); +*/ + +/* +const friends = ["Michael", "Steven", "Peter"]; +const newLength = friends.push("Jay"); +console.log(friends); +console.log(newLength); + +friends.unshift("John"); +console.log(friends); + +const popped = friends.pop(); +console.log(friends); +console.log(popped); + +friends.shift(); +console.log(friends); + +console.log(friends.indexOf("Steven")); + +console.log(friends.includes("Peter")); +console.log(friends.includes("Dan")); + +if (friends.includes("Steven")) { + console.log("You have a friend called Steven"); +} +*/ +/* +const dan = { + firstName: "Dan", + lastName: "Bekenstein", + age: 2024 - 1994, + job: "Product Manager", + friends: ["Tim", "Justin", "Greg"], +}; + +console.log(dan); +console.log(dan.lastName); +console.log(dan["lastName"]); + +const nameKey = "Name"; + +console.log(dan["first" + nameKey]); +console.log(dan["last" + nameKey]); + +// const interestedIn = prompt( +// "What do you want to know about Dan? Choose between firstName, lastName, age, job, and friends" +// ); +// console.log(dan[interestedIn]); + + +dan.location = "US"; +dan["city"] = "Boston"; + +console.log(dan); + +console.log( + `${dan.firstName} has ${dan.friends.length} friends, and his best friend is called ${dan.friends[0]}` +); + +const dan1 = { + firstName: "Dan", + lastName: "Bekenstein", + // age: 2024 - 1994, + job: "Product Manager", + friends: ["Tim", "Justin", "Greg"], + birthYear: 1994, + hasDriversLicense: true, + + calcAge: function () { + this.age = 2024 - this.birthYear; + return this.age; + }, + + getSummary: function () { + return `${this.firstName} is a ${this.calcAge()}-year old ${ + this.job + }, and he has ${this.hasDriversLicense ? "a" : "no"} driver's license.`; + }, +}; +console.log(dan1.calcAge()); + +console.log(dan1.age); + +console.log(dan1.getSummary()); +*/ + +for (let rep = 1; rep <= 10; rep++) { + console.log(`Lifting weights repetition ${rep}`); +} From 2c562384948663ad9f69b57c10bba70bcf2fb3c6 Mon Sep 17 00:00:00 2001 From: Daniel Bekenstein Date: Tue, 2 Apr 2024 21:39:36 -0400 Subject: [PATCH 06/12] Test --- 02-Fundamentals-Part-2/starter/script.js | 73 +++++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/02-Fundamentals-Part-2/starter/script.js b/02-Fundamentals-Part-2/starter/script.js index b393e3a1e5..4b66f7c545 100755 --- a/02-Fundamentals-Part-2/starter/script.js +++ b/02-Fundamentals-Part-2/starter/script.js @@ -149,6 +149,75 @@ console.log(dan1.age); console.log(dan1.getSummary()); */ -for (let rep = 1; rep <= 10; rep++) { - console.log(`Lifting weights repetition ${rep}`); +// for (let rep = 1; rep <= 10; rep++) { +// console.log(`Lifting weights repetition ${rep}`); +// } +/* +const dan = [ + "Dan", + "Bekenstein", + 2024 - 1994, + "Product Manager", + ["Tim", "Justin", "Greg"], + true, +]; + +const types = []; + +for (let i = 0; i < dan.length; i++) { + console.log(dan[i], typeof dan[i]); + + // types[i] = typeof dan[i]; + types.push(typeof dan[i]); +} + +console.log(types); + +const years = [1991, 2007, 1969, 2020]; +const ages = []; + +for (let i = 0; i < years.length; i++) { + ages.push(2024 - years[i]); +} +console.log(years, ages); + + +const dan = [ + "Dan", + "Bekenstein", + 2024 - 1994, + "Product Manager", + ["Tim", "Justin", "Greg"], +]; + +for (let i = dan.length - 1; i >= 0; i--) { + console.log(dan[i]); +} + +for (let exercise = 1; exercise < 4; exercise++) { + console.log(`----Starting exercise---- ${exercise}`); + + for (let rep = 1; rep < 6; rep++) { + console.log(`Lifting weight repetition ${rep}`); + } +} +*/ + +// for (let rep = 1; rep <= 10; rep++) { +// console.log(`Lifting weights repetition ${rep}`); +// } + +// let rep = 1; +// while (rep <= 10) { +// console.log(`Lifting weights repetition ${rep}`); +// rep++; +// } + +let dice = Math.trunc(Math.random() * 6) + 1; +// console.log(dice); + +while (dice != 6) { + console.log(`You rolled a ${dice}`); + dice = Math.trunc(Math.random() * 6) + 1; + if (dice === 6) console.log("Loop is about to end..."); } From 42220a17857f7369d94a4844e12782266c01f372 Mon Sep 17 00:00:00 2001 From: Daniel Bekenstein Date: Wed, 3 Apr 2024 20:17:43 -0400 Subject: [PATCH 07/12] 04 --- .DS_Store | Bin 8196 -> 8196 bytes 03-Developer-Skills/starter/.prettierrc | 3 ++ 03-Developer-Skills/starter/script.js | 16 +++++++ 04-HTML-CSS/.DS_Store | Bin 0 -> 8196 bytes 04-HTML-CSS/final/.DS_Store | Bin 0 -> 6148 bytes 04-HTML-CSS/final/index.html | 4 +- 04-HTML-CSS/starter/index.html | 34 ++++++++++++++ 04-HTML-CSS/starter/style1.css | 56 ++++++++++++++++++++++++ 8 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 03-Developer-Skills/starter/.prettierrc create mode 100644 04-HTML-CSS/.DS_Store create mode 100644 04-HTML-CSS/final/.DS_Store create mode 100644 04-HTML-CSS/starter/index.html create mode 100644 04-HTML-CSS/starter/style1.css diff --git a/.DS_Store b/.DS_Store index b1d95ce13be644ee985f7202e7fbe0352be5da95..eaaf854bb771c052df0f31781168129cf480e8f3 100644 GIT binary patch delta 1168 zcmeH_%TE(g7{%|AhciP;Z&RR`B1VPquwZIXMC2s|fdE!)D^QGDm;ol1Db5T?LtlU7{h}f+=V$?)kxOAa++HN)e0dD5r^PT%R_xH_G$5O|w0P>%m zT6H4-j?2H&LW=-q4Y`(`F3BxLR9VqXby8Jy>q0S0hP3F6BDxR}Qx0b#E%7imGB>VX znp4dMS|JE2N1>CJv2y9G95t1}xNL8g1^R-o=guBh&cNYO+X;Oyz*&XW?WlIa zMNc(njX^;;Pn~JQKCW9<&A6V*nnSipRV|^KQIjVN@?p-f+T4xF=VXn%CU3}FvPs^P z6!}0tl27C_`9gkx0LVcu94LhsWvE0g_M;BCO~ybg5U`yHDWkX5jCN zy#9kCZzs*kN}nhSnW@xtROD@?xwiC{N>Xc^X#Y}_qqIuVpJ?5sCcj< zZPLhj{XV9YE0vUOr2VN8KAqzBxt!PMXR@MJNtE3m(ly&SlF*$4wxLJsm8+K5M>Ae%$h%w=&lXr#%)zz0ak`_;x z1+uA`iZ<)}M-!8iqH(KGx-~*6dvVGs-mO`7bjmQD`py`trW~Mjz>(T?U9imW^B(L_ zl(;pnC5`BeX(ZV@O7nb|;D?z%uQ-X?b#5n;1u>cz88_41)@;#JkGN76rP;l~aAuJ_ zB#+5U@`}7BZ%B^3Cm+a1@`-#UKgdt=i~NQMUije0T2x~bLfDM02xAu-(S%kU!eMlx z8^?dTA8bfOC}oIoE25XUHV7%=meSg>&(8C=9A%;7q2 XVjc_GTMA#YB`lX#^c4S(qnF?xUN!D_ diff --git a/03-Developer-Skills/starter/.prettierrc b/03-Developer-Skills/starter/.prettierrc new file mode 100644 index 0000000000..544138be45 --- /dev/null +++ b/03-Developer-Skills/starter/.prettierrc @@ -0,0 +1,3 @@ +{ + "singleQuote": true +} diff --git a/03-Developer-Skills/starter/script.js b/03-Developer-Skills/starter/script.js index 939b2a2446..ec1ddd0981 100644 --- a/03-Developer-Skills/starter/script.js +++ b/03-Developer-Skills/starter/script.js @@ -1,3 +1,19 @@ // Remember, we're gonna use strict mode in all scripts now! 'use strict'; +const temps1 = [17, 21, 23]; +const temps2 = [12, 5, -4, 0, 4]; + +// function that takes a temp and number to return a string in the right format +//function that takes in an array and formats the arr + +const printForecast = function (arr) { + let forecast = '... '; + for (let i = 0; i < arr.length; i++) { + forecast += `${arr[i]}*C in ${i + 1} days ... `; + } + return forecast; +}; + +console.log(printForecast(temps1)); +console.log(printForecast(temps2)); diff --git a/04-HTML-CSS/.DS_Store b/04-HTML-CSS/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b34631316e82c84fc6ef1b908e101dc1f9460502 GIT binary patch literal 8196 zcmeHMU2GIp6h3F#vNHpP+d`pq1eb0EOe<_lixdR5e+srpr7iu1b+$9W$aJRc%oFaR`P!+=z1BE(`$GJGsR7j@<73zRO9WY!O!wdz3)k!ZN zhy$hsjq1n)kp~uffamUIa11PPK%bMpU(QU}mggsv*HJ1dEn5F6j&QEeb?r>Ct!EBfW+Ba1wY!e5TaK9x6fDCek|OU2|7UyWS!H|qc5w?+5-aZF&2SfGMO~^L9#Dq{tufc> zwa%Jpw!))r+)r#z*38rP4UD;VZrt(GtYS>J$8xsro2|CZg}p)FJni$=u;*s|_CPSr zSk5yKnIvcB%?^?#)k;3o!3p1T9q+K2^@t`?NwHbV#bs6NYB$y;n|JQ**mvOBneyc; zScSS$9VR?DzIDtpvqQQ!W;%xD9Pck!hJRupZ+TY6Hv1fX+*B%XSeYqby{39?jiw2K zI|@b7!Cb~Vm9zXaEFsIm8tb*VI%?1h9&io5iXpR0G!Lzw(Bj$%A8F5;R2!kfChbwR z&m(hXrVGJ(b&J|}l7Or*PxLgX+q8aL&zQEt46)93b%!>P7gj5*OLXp1cWZ-V?)W&F z=#d5WqC2IvX-E0W-MZ%=oG=~!R#$0^tm}+x+7KUWHH_e$s#mWm*Phn8W%ivs?48iF z=D`95*-Y5qBg?^dQa_)q)3AJZcCe2RGRw(Z6u-0`B8=rkYO~lC;aSFy;_kVu^)$V1drfRJdWe&-~^t+v-kqOh%ezed;{Occkn%YA3wxP_!(ZtEBFOo z!>{ohyn#3I7T(66@i+V(|By@T8xf4Pnr1}Zw=4qK@mBm8o4Ye}CoRx*_#!bX_u_c17sjHVMq?i=2YE801 zp}=7!AzRl>EDA<#*{M(nvC@#;vsd9!%^=`wYT7$!rmIYzkI(y}^CS2aF2m<=jnMf6 z{0P6mUkHTBO03590V)&t2yVfxn8ZeG!rizB_hKvIvl|cKGuVTN2%V#Z&ot`zJf1|G zFj~OVcm^kNiV*rTzJllRb-aLY5mw&~vHGz<*(~<<7f~lDezFjI^A4rC3X8^-h?S~& z{@;23`~O9IpJ<`T1Ca+7-ve0M(c95R>lRPX`LDop?KnNp(ZdUun-(-sp(;qni3aI7 q(b+!?sU0U#u9FJsw4l^OW$`Zp!k_;1BRM+%`S0iG{C^P7|9=1vY@v?; literal 0 HcmV?d00001 diff --git a/04-HTML-CSS/final/.DS_Store b/04-HTML-CSS/final/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0JavaScript is fun, but so is HTML & CSS!

Another heading

-

- Just another paragraph -

+

Just another paragraph

+ + + + + Learning HTML & CSS + + + +

JavaScript is fun, but so is HTML & CSS!

+

+ You can learn JavaScript without HTML and CSS, but for DOM manipulation + it's useful to have some basic ideas of HTML & CSS. You can learn more + + about me. +

+

Another Heading

+

Just another paragraph

+ + +
+

Your name here

+

Please fill in this form :)

+ + +
+ + diff --git a/04-HTML-CSS/starter/style1.css b/04-HTML-CSS/starter/style1.css new file mode 100644 index 0000000000..7e8a895526 --- /dev/null +++ b/04-HTML-CSS/starter/style1.css @@ -0,0 +1,56 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + background-color: rgb(151, 228, 247); + font-family: Arial; + font-size: 20px; + padding: 40px; +} + +h1 { + font-size: 40px; + padding-bottom: 15px; +} + +h2 { + margin-bottom: 20px; + text-align: center; +} + +p { + margin-bottom: 20px; +} + +.first { + color: rgb(234, 255, 0); +} + +#your-name { + background-color: rgb(226, 43, 189); + border: 5px solid #444; + width: 350px; + padding: 25px; + margin-top: 20px; +} + +input, +button { + padding: 10px; + font-size: 16px; +} + +a { + background-color: aliceblue; +} + +#dan-image { + width: 450px; +} + +#your-name h2 { + color: rgb(43, 226, 61); +} From b6a72fbf289ee72a60d2edd379598b7dc5b59c0b Mon Sep 17 00:00:00 2001 From: Daniel Bekenstein Date: Wed, 3 Apr 2024 21:19:40 -0400 Subject: [PATCH 08/12] Guess my number --- 05-Guess-My-Number/starter/script.js | 71 ++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/05-Guess-My-Number/starter/script.js b/05-Guess-My-Number/starter/script.js index ad9a93a7c1..497b525b2f 100644 --- a/05-Guess-My-Number/starter/script.js +++ b/05-Guess-My-Number/starter/script.js @@ -1 +1,72 @@ 'use strict'; +/* +console.log(document.querySelector('.message').textContent); +document.querySelector('.message').textContent = `Correct Number! 👍`; + +document.querySelector('.number').textContent = 13; +document.querySelector('.score').textContent = 10; + +document.querySelector('.guess').value = 23; +console.log(document.querySelector('.guess').value); + + +*/ + +let secretNumber; +const calcSecretNumber = function () { + secretNumber = Math.trunc(Math.random() * 20) + 1; +}; +let score = 20; +let highScore = 0; + +calcSecretNumber(); +// document.querySelector('.number').textContent = secretNumber; + +const wrongGuess = function () { + if (score > 1) { + score--; + document.querySelector('.score').textContent = score; + } else { + score--; + changeMessage('You lost the game! 😞'); + } +}; + +const changeMessage = function (newMessage) { + document.querySelector('.message').textContent = newMessage; +}; + +document.querySelector('.check ').addEventListener('click', function () { + const guess = Number(document.querySelector('.guess').value); + console.log(guess, typeof guess); + + if (!guess) { + changeMessage(`No number 💔`); + } else if (guess === secretNumber) { + changeMessage(`Correct number! 😎`); + document.querySelector('.number').textContent = secretNumber; + document.querySelector('body').style.backgroundColor = '#60b347'; + document.querySelector('.number').style.width = '30rem'; + if (score > highScore) { + highScore = score; + document.querySelector('.highscore').textContent = highScore; + } + } else if (guess > secretNumber) { + changeMessage(`Too high! 👇`); + wrongGuess(); + } else if (guess < secretNumber) { + changeMessage(`Too low! 👆`); + wrongGuess(); + } +}); + +document.querySelector('.again').addEventListener('click', function () { + score = 20; + document.querySelector('.score').textContent = score; + calcSecretNumber; + document.querySelector('body').style.backgroundColor = '#222'; + document.querySelector('.number').style.width = '15rem'; + changeMessage('Start guessing...'); + document.querySelector('.number').textContent = '?'; + document.querySelector('.guess').value = ''; +}); From d864b700946b93ba229a6787a26da3d8cd672bb8 Mon Sep 17 00:00:00 2001 From: Daniel Bekenstein Date: Wed, 3 Apr 2024 21:37:57 -0400 Subject: [PATCH 09/12] Modals --- 06-Modal/starter/script.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/06-Modal/starter/script.js b/06-Modal/starter/script.js index ad9a93a7c1..a319c6a98f 100644 --- a/06-Modal/starter/script.js +++ b/06-Modal/starter/script.js @@ -1 +1,23 @@ 'use strict'; + +const modal = document.querySelector('.modal'); +const overlay = document.querySelector('.overlay'); +const btnCloseModal = document.querySelector('.close-modal'); +const btnsOpenModal = document.querySelectorAll('.show-modal'); + +const openModal = function () { + modal.classList.remove('hidden'); + overlay.classList.remove('hidden'); +}; + +const closeModal = function () { + modal.classList.add('hidden'); + overlay.classList.add('hidden'); +}; + +for (let i = 0; i < btnsOpenModal.length; i++) { + btnsOpenModal[i].addEventListener('click', openModal); + + btnCloseModal.addEventListener('click', closeModal); + overlay.addEventListener('click', closeModal); +} From 7ffecb4e8846e3022c417cae0d139ca546f24c68 Mon Sep 17 00:00:00 2001 From: Daniel Bekenstein Date: Wed, 3 Apr 2024 21:49:10 -0400 Subject: [PATCH 10/12] Modal finished --- 06-Modal/starter/script.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/06-Modal/starter/script.js b/06-Modal/starter/script.js index a319c6a98f..e08b0e472f 100644 --- a/06-Modal/starter/script.js +++ b/06-Modal/starter/script.js @@ -15,9 +15,14 @@ const closeModal = function () { overlay.classList.add('hidden'); }; -for (let i = 0; i < btnsOpenModal.length; i++) { +for (let i = 0; i < btnsOpenModal.length; i++) btnsOpenModal[i].addEventListener('click', openModal); - btnCloseModal.addEventListener('click', closeModal); - overlay.addEventListener('click', closeModal); -} +btnCloseModal.addEventListener('click', closeModal); +overlay.addEventListener('click', closeModal); + +document.addEventListener('keydown', function (e) { + if (e.key === 'Escape' && !modal.classList.contains('hidden')) { + closeModal(); + } +}); From 52b4eb97fc6bc322244b31ab6edc4ee2d878771a Mon Sep 17 00:00:00 2001 From: Daniel Bekenstein Date: Wed, 3 Apr 2024 22:54:32 -0400 Subject: [PATCH 11/12] Pig Games --- 07-Pig-Game/starter/script.js | 86 +++++++++++++++++++++++++++++++++++ 07-Pig-Game/starter/style.css | 4 ++ 2 files changed, 90 insertions(+) diff --git a/07-Pig-Game/starter/script.js b/07-Pig-Game/starter/script.js index ad9a93a7c1..d56046f98e 100644 --- a/07-Pig-Game/starter/script.js +++ b/07-Pig-Game/starter/script.js @@ -1 +1,87 @@ 'use strict'; + +const player0El = document.querySelector('.player--0'); +const player1El = document.querySelector('.player--1'); +const score0El = document.querySelector('#score--0'); +const score1El = document.getElementById('score--1'); +const current0El = document.getElementById('current--0'); +const current1El = document.getElementById('current--1'); +const diceEl = document.querySelector('.dice'); +const btnNew = document.querySelector('.btn--new'); +const btnRoll = document.querySelector('.btn--roll'); +const btnHold = document.querySelector('.btn--hold'); + +let scores, currentScore, activePlayer, playing; + +//starting conditions +const init = function () { + scores = [0, 0]; + currentScore = 0; + activePlayer = 0; + playing = true; + + score0El.textContent = 0; + score1El.textContent = 0; + current0El.textContent = 0; + current1El.textContent = 0; + player0El.classList.remove('player--winner'); + player1El.classList.remove('player--winner'); + player0El.classList.add('player--active'); + player1El.classList.remove('player--active'); + diceEl.classList.add('hidden'); +}; + +init(); + +const switchPlayer = function () { + document.getElementById(`current--${activePlayer}`).textContent = 0; + currentScore = 0; + activePlayer = activePlayer === 0 ? 1 : 0; + player0El.classList.toggle('player--active'); + player1El.classList.toggle('player--active'); +}; + +//rolling dice functionality +btnRoll.addEventListener('click', function () { + if (playing) { + //1. random dice roll + const dice = Math.trunc(Math.random() * 6) + 1; + //2. display dice + diceEl.classList.remove('hidden'); + diceEl.src = `dice-${dice}.png`; + + //3. check for rolle 1: if true, switch to next player + if (dice !== 1) { + currentScore += dice; + document.getElementById(`current--${activePlayer}`).textContent = + currentScore; + } else { + switchPlayer(); + } + } +}); + +btnHold.addEventListener('click', function () { + if (playing) { + scores[activePlayer] += currentScore; + document.getElementById(`score--${activePlayer}`).textContent = + scores[activePlayer]; + + if (scores[activePlayer] >= 100) { + playing = false; + document + .querySelector(`.player--${activePlayer}`) + .classList.add('player--winner'); + document + .querySelector(`.player--${activePlayer}`) + .classList.remove('player--active'); + diceEl.classList.add('hidden'); + } else { + switchPlayer(); + } + } +}); + +btnNew.addEventListener('click', function () { + init(); +}); diff --git a/07-Pig-Game/starter/style.css b/07-Pig-Game/starter/style.css index dcf788f011..555ea263e0 100644 --- a/07-Pig-Game/starter/style.css +++ b/07-Pig-Game/starter/style.css @@ -165,3 +165,7 @@ main { font-weight: 700; color: #c7365f; } + +.hidden { + display: none; +} From 20bf0af65cb2f2a8fc8ebdd091e2bfcf327d2e09 Mon Sep 17 00:00:00 2001 From: Daniel Bekenstein Date: Wed, 3 Apr 2024 22:55:32 -0400 Subject: [PATCH 12/12] set winning to 20 --- 07-Pig-Game/starter/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/07-Pig-Game/starter/script.js b/07-Pig-Game/starter/script.js index d56046f98e..dfa880cf44 100644 --- a/07-Pig-Game/starter/script.js +++ b/07-Pig-Game/starter/script.js @@ -67,7 +67,7 @@ btnHold.addEventListener('click', function () { document.getElementById(`score--${activePlayer}`).textContent = scores[activePlayer]; - if (scores[activePlayer] >= 100) { + if (scores[activePlayer] >= 20) { playing = false; document .querySelector(`.player--${activePlayer}`)