diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000..c70fc154bf Binary files /dev/null and b/.DS_Store differ diff --git a/01-Fundamentals-Part-1/.DS_Store b/01-Fundamentals-Part-1/.DS_Store new file mode 100644 index 0000000000..6baece49c8 Binary files /dev/null and b/01-Fundamentals-Part-1/.DS_Store differ diff --git a/01-Fundamentals-Part-1/._.DS_Store b/01-Fundamentals-Part-1/._.DS_Store new file mode 100644 index 0000000000..8e82ed96c0 Binary files /dev/null and b/01-Fundamentals-Part-1/._.DS_Store differ diff --git a/01-Fundamentals-Part-1/._final b/01-Fundamentals-Part-1/._final new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/01-Fundamentals-Part-1/._final differ diff --git a/01-Fundamentals-Part-1/._starter b/01-Fundamentals-Part-1/._starter new file mode 100644 index 0000000000..a703a65b93 Binary files /dev/null and b/01-Fundamentals-Part-1/._starter differ diff --git a/01-Fundamentals-Part-1/final/._index.html b/01-Fundamentals-Part-1/final/._index.html new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/01-Fundamentals-Part-1/final/._index.html differ diff --git a/01-Fundamentals-Part-1/final/._script.js b/01-Fundamentals-Part-1/final/._script.js new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/01-Fundamentals-Part-1/final/._script.js differ diff --git a/01-Fundamentals-Part-1/starter/._assignments.js b/01-Fundamentals-Part-1/starter/._assignments.js new file mode 100644 index 0000000000..99c03224a9 Binary files /dev/null and b/01-Fundamentals-Part-1/starter/._assignments.js differ diff --git a/01-Fundamentals-Part-1/starter/._index.html b/01-Fundamentals-Part-1/starter/._index.html new file mode 100644 index 0000000000..1c1434f066 Binary files /dev/null and b/01-Fundamentals-Part-1/starter/._index.html differ diff --git a/01-Fundamentals-Part-1/starter/._script.js b/01-Fundamentals-Part-1/starter/._script.js new file mode 100644 index 0000000000..4983cf09d0 Binary files /dev/null and b/01-Fundamentals-Part-1/starter/._script.js differ diff --git a/01-Fundamentals-Part-1/starter/assignments.js b/01-Fundamentals-Part-1/starter/assignments.js new file mode 100644 index 0000000000..bbd747ee6f --- /dev/null +++ b/01-Fundamentals-Part-1/starter/assignments.js @@ -0,0 +1,132 @@ +const country = 'United States'; +const continent = 'North America'; +let population = 328000000; +let isIsland = false; +const language = 'English'; + +console.log(country); +console.log(continent); +console.log(population); +console.log(isIsland); +console.log(language); + +const halfPopulation = population / 2 / 2; +console.log(halfPopulation); +population++; +console.log(population); +const hasMorePopulationThanFinlans = population > 6000000; +console.log(hasMorePopulationThanFinlans); +const lessThanAverageCountryPopulation = population < 33000000; +const description = `${country} is in ${continent} and its ${population} million people speak ${language}`; +console.log(description); + + +//Coding Challenge #1 +const marksMass = 82; +const MarksHeight = 1.95; +const JohnsMass = 78; +const JohnsHeight = 1.68; + +const marksBMI = marksMass / (MarksHeight * MarksHeight); +const johnsBMI = JohnsMass / (JohnsHeight * JohnsHeight); + +const markHigherBMI = marksMass > johnsBMI; + +console.log(marksBMI, johnsBMI); +const averagePopulation = 33000000; +if (population > averagePopulation) { + console.log(`${country} population is about average`); + +} else { + console.log(`${country} population is ${averagePopulation - population} below averaeg `); +} + + +if (marksBMI > johnsBMI) { + + console.log(`Marks BMI(${marksBMI}) is hgher then Johns BMI(${johnsBMI})`); + +} else { + console.log(`Johns BMI(${johnsBMI}) is higher then Marks BMI(${marksBMI})`); +} + +console.log('123' < 56); + +// let numNeighbours = Number(prompt(`How many neighbours country does your country have ?`)); + +// if (numNeighbours === 1) { + +// console.log(`Only 1 neigbouring country`); +// } else if (numNeighbours > 1) { +// console.log(`Greater then 1 neigbouring country`); + +// } else { +// console.log(`No borders`); + +// } + +//LECTURE: Logical Operators + + +if (language === 'English' && population <= 50000000 && isIsland == false) { + console.log(`Your should live in the ${country}`); +} else { + console.log(`${country} doesnt meet your criteria`); + +} + + +//LECTURE: The switch Statement + + +switch (language) { + case `chinese`, `manderine`, `Chinese`: + console.log(`MOST number of native speakers`); + break; + case `spanish`: + console.log(`2nd most native speakers`); + break; + case `english`, `English`: + console.log(`3rd most native speakers`) + break; + + default: + console.log(`also a great language too`); + break; +} + +//LECTURE: The Conditional (Ternary) Operator +console.log(`${country} populations is ${population > 33000000 ? "above" : "below"} average`) +//const populationOver33mil = population > 33000000 ? console.log(`${ country } is above average`) : console.log(`${ country } is below averae`); + + +//Coding Challenge #3 + +const dolphinsScore1 = 98; +const dolphinsScore2 = 109; +const dolphinsScore3 = 96; + +const koalasScore1 = 88; +const koalasScore2 = 91; +const koalasScore3 = 110; +const MINSCORE = 100; + + +const dolphinsAverageScore = (dolphinsScore1 + dolphinsScore2 + dolphinsScore3) / 3; +const koalasAverageScore = (koalasScore1 + koalasScore2 + koalasScore3) / 3; + +if (dolphinsAverageScore >= MINSCORE && dolphinsAverageScore > koalasAverageScore) { + console.log(`Dolphines Avergge score(${dolphinsAverageScore}) greater than koalas average score(${koalasAverageScore})`); +} else if (dolphinsAverageScore < koalasAverageScore && koalasAverageScore >= MINSCORE) { + console.log(`Koalas Avergge score(${koalasAverageScore}) greater than dalphins average score(${dolphinsAverageScore})`); + +} else if (dolphinsAverageScore === koalasAverageScore && koalasAverageScore >= MINSCORE) { + console.log(`We have a draw`); +} + +//Coding Challenge #4 +const bill = 275; +const tip = bill >= 50 && bill <= 300 ? bill * (15 / 100) : bill * (20 / 100); +console.log(`${tip}% `); + +console.log(`The bill was ${bill}, the tip was ${tip}, and the total value ${bill + tip}`); diff --git a/01-Fundamentals-Part-1/starter/index.html b/01-Fundamentals-Part-1/starter/index.html index 59529c7923..2338a305b0 100755 --- a/01-Fundamentals-Part-1/starter/index.html +++ b/01-Fundamentals-Part-1/starter/index.html @@ -1,29 +1,34 @@ - - - - - JavaScript Fundamentals – Part 1 - - - -

JavaScript Fundamentals – Part 1

- - + + + + + + JavaScript Fundamentals – Part 1 + + + + +

JavaScript Fundamentals – Part 1

+ + + + \ No newline at end of file diff --git a/01-Fundamentals-Part-1/starter/script.js b/01-Fundamentals-Part-1/starter/script.js new file mode 100644 index 0000000000..c3640957c4 --- /dev/null +++ b/01-Fundamentals-Part-1/starter/script.js @@ -0,0 +1,2 @@ +console.log("Hello World"); +alert("Javascript is FUN"); \ No newline at end of file diff --git a/02-Fundamentals-Part-2/.DS_Store b/02-Fundamentals-Part-2/.DS_Store new file mode 100644 index 0000000000..4ee372ccf2 Binary files /dev/null and b/02-Fundamentals-Part-2/.DS_Store differ diff --git a/02-Fundamentals-Part-2/._.DS_Store b/02-Fundamentals-Part-2/._.DS_Store new file mode 100644 index 0000000000..8e82ed96c0 Binary files /dev/null and b/02-Fundamentals-Part-2/._.DS_Store differ diff --git a/02-Fundamentals-Part-2/._final b/02-Fundamentals-Part-2/._final new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/02-Fundamentals-Part-2/._final differ diff --git a/02-Fundamentals-Part-2/._starter b/02-Fundamentals-Part-2/._starter new file mode 100644 index 0000000000..bc1749da0f Binary files /dev/null and b/02-Fundamentals-Part-2/._starter differ diff --git a/02-Fundamentals-Part-2/final/._index.html b/02-Fundamentals-Part-2/final/._index.html new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/02-Fundamentals-Part-2/final/._index.html differ diff --git a/02-Fundamentals-Part-2/final/._script.js b/02-Fundamentals-Part-2/final/._script.js new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/02-Fundamentals-Part-2/final/._script.js differ diff --git a/02-Fundamentals-Part-2/starter/._index.html b/02-Fundamentals-Part-2/starter/._index.html new file mode 100644 index 0000000000..cf50d7e22d Binary files /dev/null and b/02-Fundamentals-Part-2/starter/._index.html differ diff --git a/02-Fundamentals-Part-2/starter/._script.js b/02-Fundamentals-Part-2/starter/._script.js new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/02-Fundamentals-Part-2/starter/._script.js differ diff --git a/02-Fundamentals-Part-2/starter/script.js b/02-Fundamentals-Part-2/starter/script.js index e69de29bb2..78dbe160f0 100755 --- a/02-Fundamentals-Part-2/starter/script.js +++ b/02-Fundamentals-Part-2/starter/script.js @@ -0,0 +1,276 @@ +'use strict'; +let hasDriversLicense = false; +const pastTest = true; + +if (pastTest) hasDriversLicense = true; +if (hasDriversLicense) console.log(`I Can Drive :D`); + + +//JavaScript Fundamentals – Part 2 + +function describeCountry(country, population, capitalCity) { + + return `${country} has ${population} million people and its capital city is ${capitalCity} `; +} +const unitedStates = describeCountry("United States", 350, "Washington DC"); +console.log(unitedStates); + +//LECTURE: Function Declarations vs. Expressions + +//function declaration +function percentageOfWorld1(population) { + + return (population / 7900) * 100; +}; + +console.log(percentageOfWorld1(1441)); + + + +// function expression +const percentageOfWorld2 = function (population) { + return (population / 7900) * 100; + +}; + +console.log(percentageOfWorld2(1441)); + +// Arrow function + +const percentageOfWorld3 = (population) => (population / 7900) * 100; +console.log(percentageOfWorld3(3944)); + + +function describePopulation(population, country) { + + return `${country} has ${population} million people which is ${percentageOfWorld1(population)} of the world`; +} + +console.log(describePopulation(1441, "United States")); + + +// #coding Challenge 1 + +//dolphins and the Koalas + +// + +const dolphinsScore1 = 85; +const dolphinsScore2 = 54; +const dolphinsScore3 = 41; + +const koalasScore1 = 23; +const koalasScore2 = 34; +const koalasScore3 = 27; + +function calcAverage(score1, score2, score3) { + return (score1 + score2 + score3) / 3; +} + + +const dolphinsAverageScore = calcAverage(dolphinsScore1, dolphinsScore2, dolphinsScore3); +const KoalasAverageScoer = calcAverage(koalasScore1, koalasScore2, koalasScore3); + +console.log(dolphinsAverageScore, KoalasAverageScoer); + +function checkWinner(teamName1, team1Score, teamName2, team2Score) { + if (team1Score >= 2 * team2Score) { + console.log(`${teamName1} wins ${team1Score} vs ${team2Score}`); + } else if (team2Score >= 2 * team1Score) { + console.log(`${teamName2} wins ${team2Score} vs ${team1Score}`); + + } +} + +checkWinner('Dolphins', dolphinsAverageScore, "Koalas", KoalasAverageScoer); + + + +const populations = [2290, 9000, 3193, 8800]; +if (populations.length === 4) { + console.log(`true`); +} else { + console.log(`false`); +} +const percentages = [percentageOfWorld1(populations[0]), percentageOfWorld1(populations[1]), percentageOfWorld1(populations[2]), percentageOfWorld1(populations[3])]; +console.log(percentages); + + +const friends = ["Shaun", "Gilbert", "Adam"]; +friends.push("John"); +const popped = friends.pop(); +console.log(popped); +friends.unshift("Johnny"); +console.log(friends); + +const neighbours = Array('Mexico', 'Canada'); +neighbours.push("Utopia"); +neighbours.pop(); // removing it from the array + +console.log(neighbours); +if (neighbours.includes("Germany")) { + +} else { + console.log(`Not in a centrual European Country :D`); +} + +const neighboursLength = neighbours.length; +const indexOfCanada = neighbours.indexOf("Canada"); +neighbours[indexOfCanada] = "Wakanda"; +console.log(neighbours); + +const bills = Array(22, 295, 176, 440, 38, 105, 10, 1100, 86, 52); +const tips = Array(); +const total = Array(); +function calTip(billAmount) { + + if (billAmount >= 50 && billAmount <= 300) { + return billAmount * .15; + } else { + return billAmount * .20; + } +} + +for (let i = 0; i < bills.length; i++) { + tips.push(calTip(bills[i])); + total.push(tips[i] + bills[i]); + +} +//tips.push(calTip(bills[0], calTip(bills[1]), calTip(bills[2]))); +//total.push(bills[0] + tips[0], bills[1] + tips[1], bills[2] + tips[2]); + + + + +console.log(` Tip is ${calTip(436)}`); + +//create an aobject +const myCountry = { + country: "United States", + capital: "Washington DC", + language: "English", + populations: 321, + neighbours: 2, + describe: function () { + console.log(`${this.country} has ${this.populations} million ${this.language} speaking people, ${this.neighbours} neighbouring countries and a capital called ${this.capital}`); + }, + checkIsland: function () { + this.isIsland = this.neighbours > 0 ? true : false; + return this.isIsland; + } + + + + +}; + +myCountry.describe(); + +myCountry.populations = myCountry.populations + 2; // increate by 2 million using dot notation +console.log(`Population is ${myCountry.populations}`); + +myCountry["populations"] = myCountry['populations'] - 2; + +console.log(`Population is ${myCountry.populations}`); +myCountry.checkIsland(); +console.log(myCountry.isIsland); +//console.log(myCountry.describe()); + +// LECTURE: Dot vs. Bracket Notation + + +//Coding Challenge #3 +// 1. Foreachofthem,createanobjectwithpropertiesfortheirfullname,mass,and height (Mark Miller and John Smith) +const markkMiller = { + fullName: "Mark Miller", + mass: 78, + height: 1.69, + calcBMI: function () { + return this.calcBMI = this.mass / this.height ** 2; + + } + +}; + +const johnSmith = { + fullName: "John Smith", + mass: 92, + height: 1.95, + calcBMI: function () { + return this.calcBMI = this.mass / (this.height * this.height); + + } + +}; + + +if (markkMiller.calcBMI() > johnSmith.calcBMI()) { + console.log(`${markkMiller.fullName} BMI(${markkMiller.calcBMI}) is Higher then ${johnSmith.fullName} BMI(${johnSmith.calcBMI})`); +} else { + + console.log(`${johnSmith.fullName} BMI(${johnSmith.calcBMI}) is Higher then ${markkMiller.fullName} BMI(${markkMiller.calcBMI})`); + +} + + +//LECTURE: Iteration: The for Loop +//'Voter number 1 is currently voting' +for (let x = 1; x <= 10; x++) { + // console.log(`Voter Number ${x} is curerntly voting`); +} + + +//LECTURE: Looping Arrays, Breaking and Continuing + +const percentages2 = []; +for (let x = 0; x < populations.length; x++) { + percentages2.push(percentageOfWorld1(populations[x])); + +} +for (let b = 0; b < percentages2.length; b++) { + if (percentages[b] === percentages2[b]) { + console.log("Match"); + } + +} + +// LECTURE: Looping Backwards and Loops in Loops +const listOfNeighbours = [['Canada', 'Mexico'], ['Spain'], ['Norway', 'Sweden', 'Russia']]; +for (let x = 0; x < listOfNeighbours.length; x++) { + + for (let y = 0; y < listOfNeighbours[x].length; y++) { + + console.log(listOfNeighbours[x][y]); + + } +} + + +const percentages3 = []; +let conter = 0; +while (conter < populations.length) { + + percentages3.push(percentageOfWorld2(populations[conter])); + console.log(Math.trunc(percentages3[conter])); + conter++; +} + +//Coding Challenge #4 + +console.log(tips); +console.log(total); + +const calcAverage2 = function (arrayA) { + + let result = 0; + for (let i = 0; i < arrayA.length; i++) { + + result = result + arrayA[i]; + + + } + console.log(`total ${result}`); + return result / arrayA.length; +} +const arrayExample = Array(70, 99, 80, 78); +console.log(calcAverage2(arrayExample)); \ No newline at end of file diff --git a/03-Developer-Skills/._final b/03-Developer-Skills/._final new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/03-Developer-Skills/._final differ diff --git a/03-Developer-Skills/._starter b/03-Developer-Skills/._starter new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/03-Developer-Skills/._starter differ diff --git a/03-Developer-Skills/final/._.prettierrc b/03-Developer-Skills/final/._.prettierrc new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/03-Developer-Skills/final/._.prettierrc differ diff --git a/03-Developer-Skills/final/._index.html b/03-Developer-Skills/final/._index.html new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/03-Developer-Skills/final/._index.html differ diff --git a/03-Developer-Skills/final/._script.js b/03-Developer-Skills/final/._script.js new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/03-Developer-Skills/final/._script.js differ diff --git a/03-Developer-Skills/starter/._index.html b/03-Developer-Skills/starter/._index.html new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/03-Developer-Skills/starter/._index.html differ diff --git a/03-Developer-Skills/starter/._script.js b/03-Developer-Skills/starter/._script.js new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/03-Developer-Skills/starter/._script.js differ diff --git a/03-Developer-Skills/starter/.prettierrc b/03-Developer-Skills/starter/.prettierrc new file mode 100644 index 0000000000..ef8f3304f1 --- /dev/null +++ b/03-Developer-Skills/starter/.prettierrc @@ -0,0 +1,4 @@ +{ + "singleQuote": false, + "arrowParens": "always" +} \ No newline at end of file diff --git a/03-Developer-Skills/starter/script.js b/03-Developer-Skills/starter/script.js index 939b2a2446..b57b8abf62 100644 --- a/03-Developer-Skills/starter/script.js +++ b/03-Developer-Skills/starter/script.js @@ -1,3 +1,39 @@ // Remember, we're gonna use strict mode in all scripts now! -'use strict'; +"use strict"; +console.log("Hello workd"); + +// function expression +const myFunction = function (name) { + console.log(`Hello everyone ${name} `); +}; + +myFunction("Alex"); + +const measureKelvin = function () { + const measurement = { + type: "temp", + unit: "celsious", + value: Number(prompt("Degree value")), + }; + + const kelvin = measureKelvin.value + 247; + return kelvin; +}; + +//Developer Skills & Editor Setup +//Coding Challenge #1 +const printForecast = function (arr) { + let res = ""; + for (let i = 0; i < arr.length; i++) { + //res.concat(`${arr[i]} oC in ${i} days...`); + res += `... ${arr[i]}oC in day ${i + 1}`; + //console.log(`${i}`); + } + return res; +}; + +const data1 = [17, 21, 23]; +const data2 = [12, 5, -5, 0, 4]; +console.log(printForecast(data1)); +console.log(printForecast(data2)); diff --git a/04-HTML-CSS/._final b/04-HTML-CSS/._final new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/04-HTML-CSS/._final differ diff --git a/04-HTML-CSS/final/._index.html b/04-HTML-CSS/final/._index.html new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/04-HTML-CSS/final/._index.html differ diff --git a/04-HTML-CSS/final/._style.css b/04-HTML-CSS/final/._style.css new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/04-HTML-CSS/final/._style.css differ diff --git a/04-HTML-CSS/index.html b/04-HTML-CSS/index.html new file mode 100644 index 0000000000..237c70d2be --- /dev/null +++ b/04-HTML-CSS/index.html @@ -0,0 +1,29 @@ + + + + + + + + Document + + +

hello goyes

+

+ whats going on guys its a me checking out the css and html +

+
whats going on people
+

just doing some things thart i loev to lear

+ site here + +
+

Your name here

+

please fill in the blank

+ + +
+ + diff --git a/04-HTML-CSS/style.css b/04-HTML-CSS/style.css new file mode 100644 index 0000000000..fe29c12ffb --- /dev/null +++ b/04-HTML-CSS/style.css @@ -0,0 +1,48 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + background-color: rgb(131, 131, 46); + font-family: Arial; + font-size: 20px; + padding: 50px; +} + +h1 { + font-size: 40px; + margin-bottom: 25px; +} + +.first { + color: red; +} + +#your-name { + background-color: burlywood; + color: rgb(0, 255, 8); + border: 5px solid rgb(21, 103, 128); + width: 400px; + text-align: center; +} + +input, +button { + padding: 10px; + font-size: 16px; +} + +p { + margin-bottom: 20px; +} + +#course-name { + width: 300px; + /* height: 300px; */ +} + +#your-name h2 { + color: olivedrab; +} diff --git a/05-Guess-My-Number/._final b/05-Guess-My-Number/._final new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/05-Guess-My-Number/._final differ diff --git a/05-Guess-My-Number/._starter b/05-Guess-My-Number/._starter new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/05-Guess-My-Number/._starter differ diff --git a/05-Guess-My-Number/final/._.prettierrc b/05-Guess-My-Number/final/._.prettierrc new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/05-Guess-My-Number/final/._.prettierrc differ diff --git a/05-Guess-My-Number/final/._index.html b/05-Guess-My-Number/final/._index.html new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/05-Guess-My-Number/final/._index.html differ diff --git a/05-Guess-My-Number/final/._script.js b/05-Guess-My-Number/final/._script.js new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/05-Guess-My-Number/final/._script.js differ diff --git a/05-Guess-My-Number/final/._style.css b/05-Guess-My-Number/final/._style.css new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/05-Guess-My-Number/final/._style.css differ diff --git a/05-Guess-My-Number/starter/._.prettierrc b/05-Guess-My-Number/starter/._.prettierrc new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/05-Guess-My-Number/starter/._.prettierrc differ diff --git a/05-Guess-My-Number/starter/._index.html b/05-Guess-My-Number/starter/._index.html new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/05-Guess-My-Number/starter/._index.html differ diff --git a/05-Guess-My-Number/starter/._script.js b/05-Guess-My-Number/starter/._script.js new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/05-Guess-My-Number/starter/._script.js differ diff --git a/05-Guess-My-Number/starter/._style.css b/05-Guess-My-Number/starter/._style.css new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/05-Guess-My-Number/starter/._style.css differ diff --git a/05-Guess-My-Number/starter/script.js b/05-Guess-My-Number/starter/script.js index ad9a93a7c1..7e7314a288 100644 --- a/05-Guess-My-Number/starter/script.js +++ b/05-Guess-My-Number/starter/script.js @@ -1 +1,54 @@ 'use strict'; + +let secreteNumber; +let score; +let guess; +let highscore = 0; +function initGame() { + score = 20; + secreteNumber = Number(Math.floor(Math.random() * 20) + 1); + document.querySelector('body').style.backgroundColor = '#222'; + document.querySelector('.score').textContent = score; + document.querySelector('.message').textContent = 'Start Guessing..'; + document.querySelector('.number').textContent = '?'; + document.querySelector('.guess').value = ''; + document.querySelector('.number').style.width = '15rem'; + + console.log(secreteNumber); +} + +initGame(); + +document.querySelector('.check').addEventListener('click', function () { + const guess = Number(document.querySelector('.guess').value); + + if (!guess) { + document.querySelector('.message').textContent = 'No Number Entered'; + } else if (guess === secreteNumber) { + // Turn Background Color Green + document.querySelector('.message').textContent = 'Correct Number'; + document.querySelector('body').style.backgroundColor = '#008000'; + document.querySelector('.number').textContent = secreteNumber; + + if (score > highscore) { + highscore = score; + document.querySelector('.highscore').textContent = score; + } + } else if (guess !== secreteNumber) { + if (score > 1) { + const bMessage = guess > secreteNumber ? 'Too High' : 'Too Low '; + document.querySelector('.message').textContent = bMessage; + score--; + + document.querySelector('.score').textContent = score; + } else { + document.querySelector('.message').textContent = 'You Lose'; + document.querySelector('.number').style.width = '30rem'; + document.querySelector('.score').textContent = 0; + } + } +}); + +document.querySelector('.again').addEventListener('click', function () { + initGame(); +}); diff --git a/06-Modal/._final b/06-Modal/._final new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/06-Modal/._final differ diff --git a/06-Modal/._starter b/06-Modal/._starter new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/06-Modal/._starter differ diff --git a/06-Modal/final/._.prettierrc b/06-Modal/final/._.prettierrc new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/06-Modal/final/._.prettierrc differ diff --git a/06-Modal/final/._index.html b/06-Modal/final/._index.html new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/06-Modal/final/._index.html differ diff --git a/06-Modal/final/._script.js b/06-Modal/final/._script.js new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/06-Modal/final/._script.js differ diff --git a/06-Modal/final/._style.css b/06-Modal/final/._style.css new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/06-Modal/final/._style.css differ diff --git a/06-Modal/starter/._.prettierrc b/06-Modal/starter/._.prettierrc new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/06-Modal/starter/._.prettierrc differ diff --git a/06-Modal/starter/._index.html b/06-Modal/starter/._index.html new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/06-Modal/starter/._index.html differ diff --git a/06-Modal/starter/._script.js b/06-Modal/starter/._script.js new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/06-Modal/starter/._script.js differ diff --git a/06-Modal/starter/._style.css b/06-Modal/starter/._style.css new file mode 100644 index 0000000000..a42d8a73f8 Binary files /dev/null and b/06-Modal/starter/._style.css differ diff --git a/06-Modal/starter/script.js b/06-Modal/starter/script.js index ad9a93a7c1..f3cc55173c 100644 --- a/06-Modal/starter/script.js +++ b/06-Modal/starter/script.js @@ -1 +1,32 @@ 'use strict'; + +const modal = document.querySelector('.modal'); +const overlay = document.querySelector('.overlay'); +const btnClosedModal = document.querySelector('.close-modal'); +const btnOpenModal = document.querySelectorAll('.show-modal'); + +const openModal = function () { + //openModel.classList.remove('hidden'); + modal.classList.remove('hidden'); + overlay.classList.remove('hidden'); +}; + +const closeModal = function () { + modal.classList.add('hidden'); + overlay.classList.add('hidden'); +}; +for (let x = 0; x < btnOpenModal.length; x++) { + btnOpenModal[x].addEventListener('click', openModal); +} + +btnClosedModal.addEventListener('click', closeModal); +overlay.addEventListener('click', closeModal); + +const btnClose = function (e) { + closeModal(); +}; + +document.addEventListener('keydown', function (e) { + console.log(e.key); + if (e.key === 'Escape') closeModal(); +}); diff --git a/07-Pig-Game/starter/script.js b/07-Pig-Game/starter/script.js index ad9a93a7c1..75f0e86906 100644 --- a/07-Pig-Game/starter/script.js +++ b/07-Pig-Game/starter/script.js @@ -1 +1,133 @@ 'use strict'; + +const scoreElement0 = document.querySelector('#score--0'); +const scoreElement1 = document.getElementById('score--1'); +const diceElement = document.querySelector('.dice'); +const btnNew = document.querySelector('.btn--new'); +const btnRoll = document.querySelector('.btn--roll'); +const btnHold = document.querySelector('.btn--hold'); +const currentElement0 = document.getElementById('current--0'); +const currentElement1 = document.getElementById('current--1'); + +const playerOneElement = document.querySelector('.player--0'); +const playerTwoElement = document.querySelector('.player--1'); + +const score = [0, 0]; +let activePlayer = 0; +let currentScore = 0; +let isPlaying = true; + +const init = function () { + //reset aind init method + score[0] = 0; + score[1] = 0; + activePlayer = 0; + currentScore = 0; + isPlaying = true; + + isPlaying = true; + + // reset current scoe + currentElement0.textContent = 0; + currentElement1.textContent = 0; + + //Remove Winner Height + document.querySelector(`.player--0`).classList.remove(`player--winner`); + document.querySelector(`.player--1`).classList.remove(`player--winner`); + //Fixed Bug for removing player wiinner after win by adding remove player--0 and player--1 winners + + // remove background tap + playerOneElement.classList.remove(`player-active`); + playerOneElement.classList.add(`player--active`); + + // Switch Active Player + activePlayer = 0; + + // current score reset + currentScore = 0; + + score[0] = 0; + score[1] = 0; + + document.getElementById(`score--0`).textContent = 0; + document.getElementById(`score--1`).textContent = 0; + + // Hide Dice + diceElement.classList.add('Hidden'); +}; + +init(); +// initializes variables and reset game +scoreElement0.textContent = 0; +scoreElement1.textContent = 0; +diceElement.classList.add('hidden'); + +const btnRole = document.querySelector('.btn--roll'); +const diceImage = document.querySelector('.dice'); + +const switchPlayer = function () { + // switch to next player.. + + document.getElementById(`current--${activePlayer}`).textContent = 0; + activePlayer = activePlayer === 0 ? 1 : 0; + currentScore = 0; + + // Toogle method for switching background collor + playerOneElement.classList.toggle('player--active'); + playerTwoElement.classList.toggle('player--active'); + + //toogle + + //reset both current scores to 0; + currentElement0.textContent = 0; + currentElement1.textContent = 0; +}; + +btnRoll.addEventListener('click', function () { + if (isPlaying) { + const MAXNUMBER = 6; + const dice = Math.floor(Math.random() * MAXNUMBER + 1); + + diceElement.classList.remove('hidden'); + diceElement.src = `dice-${dice}.png`; + + //starts on player 1 + // + + if (dice !== 1) { + // add to current score + currentScore += dice; + document.getElementById(`current--${activePlayer}`).textContent = + currentScore; + } else { + switchPlayer(); + } + } +}); + +btnHold.addEventListener('click', function () { + if (isPlaying) { + console.log(`hold`); + // Add player score + score[activePlayer] += currentScore; + + document.getElementById(`score--${activePlayer}`).textContent = + score[activePlayer]; + + if (score[activePlayer] >= 20) { + isPlaying = false; + diceElement.classList.add(`hidden`); + document + .querySelector(`.player--${activePlayer}`) + .classList.add('player--winner'); + + document + .querySelector(`.player--${activePlayer}`) + .classList.remove('player--active'); + } else { + switchPlayer(); + } + } +}); + +btnNew.addEventListener('click', init); diff --git a/07-Pig-Game/starter/style.css b/07-Pig-Game/starter/style.css index dcf788f011..5d29703908 100644 --- a/07-Pig-Game/starter/style.css +++ b/07-Pig-Game/starter/style.css @@ -165,3 +165,8 @@ main { font-weight: 700; color: #c7365f; } + + +.hidden{ + display: none; +} \ No newline at end of file diff --git a/09-Data-Structures-Operators/starter/script.js b/09-Data-Structures-Operators/starter/script.js index 2cc0fea5a0..e219adc499 100644 --- a/09-Data-Structures-Operators/starter/script.js +++ b/09-Data-Structures-Operators/starter/script.js @@ -26,4 +26,33 @@ const restaurant = { close: 24, }, }, + orderPasta: function (ing1, ing2, ing3) { + console.log(`Your Pasta order has ${ing1}, ${ing2}, and ${ing3}`); + }, }; + +// +console.log(`whats going on people`); +const { name, categories } = restaurant; + +// spread operator +const newMenu = [...restaurant.mainMenu]; +console.log(newMenu); +const newMenuCopy = [...newMenu, ...restaurant.mainMenu]; +console.log(newMenuCopy); + +const ingredients = [ + prompt('Enter 1st ingredients'), + prompt('Enter 2nd ingredients'), + prompt('Enter last ingredients'), +]; + +restaurant.orderPasta(...ingredients); + +// create shallow copy of object + +const restaurant2 = { ...restaurant }; + +// create shallow copy woth custom property +const restaurant3 = { founder: 1998, ...restaurant }; +console.log(restaurant3); diff --git a/11-Arrays-Bankist/.DS_Store b/11-Arrays-Bankist/.DS_Store new file mode 100644 index 0000000000..889e342137 Binary files /dev/null and b/11-Arrays-Bankist/.DS_Store differ diff --git a/11-Arrays-Bankist/starter/script.js b/11-Arrays-Bankist/starter/script.js index 05b54ddf31..13e57dd616 100644 --- a/11-Arrays-Bankist/starter/script.js +++ b/11-Arrays-Bankist/starter/script.js @@ -74,3 +74,20 @@ const currencies = new Map([ const movements = [200, 450, -400, 3000, -650, -130, 70, 1300]; ///////////////////////////////////////////////// + +const displayMovements = function name(movements) { + containerMovements.innerHTML = ' '; + + movements.forEach((num, i) => { + let type = num > 0 ? `deposit` : `withdrawal`; + + let str = `
+
${type}
+
${num}
+
`; + + containerMovements.insertAdjacentHTML('afterbegin', str); + }); +}; + +displayMovements(account1.movements); diff --git a/11-Arrays-Bankist/starter/style.css b/11-Arrays-Bankist/starter/style.css index 05dcf39618..c0d99c650a 100644 --- a/11-Arrays-Bankist/starter/style.css +++ b/11-Arrays-Bankist/starter/style.css @@ -16,7 +16,7 @@ html { } body { - font-family: "Poppins", sans-serif; + font-family: 'Poppins', sans-serif; color: #444; background-color: #f3f3f3; height: 100vh; @@ -94,7 +94,7 @@ nav { gap: 2rem; /* NOTE This creates the fade in/out anumation */ - opacity: 0; + opacity: 100; transition: all 1s; }