From e084c357a8b5b5935dfadcb738b0a80ca873fa78 Mon Sep 17 00:00:00 2001 From: BGDNbgdn Date: Tue, 30 Jul 2024 15:15:34 +0200 Subject: [PATCH 1/6] testing updt --- 01-Fundamentals-Part-1/starter/index.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/01-Fundamentals-Part-1/starter/index.html b/01-Fundamentals-Part-1/starter/index.html index 59529c7923..deff3d62d7 100755 --- a/01-Fundamentals-Part-1/starter/index.html +++ b/01-Fundamentals-Part-1/starter/index.html @@ -22,6 +22,13 @@ color: white; } + +

JavaScript Fundamentals – Part 1

From d26766f9c69372ac31bbd4db40176da8d559ff6d Mon Sep 17 00:00:00 2001 From: BGDNbgdn Date: Tue, 30 Jul 2024 16:15:29 +0200 Subject: [PATCH 2/6] updt --- 01-Fundamentals-Part-1/starter/index.html | 67 ++++++++++++----------- 01-Fundamentals-Part-1/starter/script.js | 0 NOTES | 9 +++ 3 files changed, 43 insertions(+), 33 deletions(-) create mode 100644 01-Fundamentals-Part-1/starter/script.js create mode 100644 NOTES diff --git a/01-Fundamentals-Part-1/starter/index.html b/01-Fundamentals-Part-1/starter/index.html index deff3d62d7..d3c6979eed 100755 --- a/01-Fundamentals-Part-1/starter/index.html +++ b/01-Fundamentals-Part-1/starter/index.html @@ -1,36 +1,37 @@ - - - - - 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..e69de29bb2 diff --git a/NOTES b/NOTES new file mode 100644 index 0000000000..6100b23e09 --- /dev/null +++ b/NOTES @@ -0,0 +1,9 @@ +console.log(typeof true); +// Gives the type of a variable + + +firstname = "Bogdan"; +const jonasnew = `I'm ${firstname}`; +// Use `` saves time, no need to use operators for strings, and dont bother with spaces. + +\n\ to skip to the next line or just use `` and enter \ No newline at end of file From 5ac5f8beaa5198a62305eb40a32c83a57a5e6c57 Mon Sep 17 00:00:00 2001 From: BGDNbgdn Date: Tue, 30 Jul 2024 23:11:09 +0200 Subject: [PATCH 3/6] UPDT --- 01-Fundamentals-Part-1/starter/script.js | 4 + 02-Fundamentals-Part-2/starter/script.js | 5 + NOTES | 117 ++++++++++++++++++++++- 3 files changed, 124 insertions(+), 2 deletions(-) diff --git a/01-Fundamentals-Part-1/starter/script.js b/01-Fundamentals-Part-1/starter/script.js index e69de29bb2..fd42dffea0 100644 --- a/01-Fundamentals-Part-1/starter/script.js +++ b/01-Fundamentals-Part-1/starter/script.js @@ -0,0 +1,4 @@ +const age = 23; +const drink = age >= 18 ? "wine" : "water"; + +console.log(`I like to drink ${age >= 18 ? "wine" : "water"}`); diff --git a/02-Fundamentals-Part-2/starter/script.js b/02-Fundamentals-Part-2/starter/script.js index e69de29bb2..20fc5847cb 100755 --- a/02-Fundamentals-Part-2/starter/script.js +++ b/02-Fundamentals-Part-2/starter/script.js @@ -0,0 +1,5 @@ +"use strict"; + +const calcage2 = (birthyear) => 2037 - birthyear; +const age = calcage2(1991); +console.log(age); diff --git a/NOTES b/NOTES index 6100b23e09..e8187f1ce6 100644 --- a/NOTES +++ b/NOTES @@ -3,7 +3,120 @@ console.log(typeof true); firstname = "Bogdan"; -const jonasnew = `I'm ${firstname}`; +const jonasnew = `I'm ${firstname}, i am 20 yo`; // Use `` saves time, no need to use operators for strings, and dont bother with spaces. -\n\ to skip to the next line or just use `` and enter \ No newline at end of file +\n\ to skip to the next line or just use `` and enter + + +/* 5 falsy values : 0, '', undefined, null, NaN +(false) all of them become false when converted to boolean. Any other value will be ocnverted to true. +For example +const money = 0 +if (money){ + console.log('hello') +} else { + console.log('this will be console logged since money = 0 = false') +} +*/ + +/* loose equality operator '18' == 18 will return true, while '18' === 18 returns false +const favourite = Number(prompt("what's your fav number ? ")); + +console.log(favourite); +console.log(typeof favourite); + +if (favourite === 23) { + console.log("cool 23 is great"); +} + + +!== operator for not equal + */ + + +//Logic operators : +&& for AND +|| for OR +! for Opposit + + +//THE SWITCH STATEMENT, allows to write faster than if, else if, else... + +const day = 'monday' + +switch(day){ + case 'monday': + console.log('this will print out if monday, use break otherwise it will just go on and on') + break + case 'tuesday': + case 'wednesday': + console.log('this will printout if tuesday or wednesday') + case 'thursday....' +} + +//CONDITIONAL (TERNARY) OPERATOR +const age = 23 +const drink = age >= 18 ? 'wine' : 'water' + +console.log(I like to drink ${age >= 18 ? 'wine' : 'water'}) + + +// to avoid hidden erors write this on the first line of every js file +'use strict' + + + +//////FUNCTIONS FUNCTIONS FUNCTIONS FUNCTIONS ////// + +//CREATE A FUNCTION (this way you can call this function even before declaring it) +function logger(name) { + return `Hello ${name}`; +} +const sentence = logger("Bogdan"); +console.log(sentence); + +//FUNCTION EXPRESSION (need to store it in variable since it produce a value) (cannont call it before defining it) +const calcAge = function (birthyear) { + return 2037 - birthyear; +} +const age = calcAge(1991); +console.log(age); + +//ARROW FUNCTION (also expression function), (use parantheses for multiple parameters) +const calcage2 = birthyear => 2037 - birthyear; +const age2 = calcage2(1991) +console.log(age2) + +// 3 types tgether + +function calcAge(birthyear){ + return 2037 - birthyear; +} + + const calcAge = function (birthyear){ + return 2037 - birthyear; + } + + const calcAge = birthyear => 2037 - birthyear; + + + + + + + + + + + + + + + + + + + + + + From e53d1da2899fb764af16c37d9b308bdf794b3ad9 Mon Sep 17 00:00:00 2001 From: BGDNbgdn Date: Wed, 31 Jul 2024 23:36:23 +0200 Subject: [PATCH 4/6] updt --- 02-Fundamentals-Part-2/starter/script.js | 8 +- NOTES | 122 ++++++++++++++++++++++- 2 files changed, 126 insertions(+), 4 deletions(-) diff --git a/02-Fundamentals-Part-2/starter/script.js b/02-Fundamentals-Part-2/starter/script.js index 20fc5847cb..f4b31efcdb 100755 --- a/02-Fundamentals-Part-2/starter/script.js +++ b/02-Fundamentals-Part-2/starter/script.js @@ -1,5 +1,7 @@ "use strict"; -const calcage2 = (birthyear) => 2037 - birthyear; -const age = calcage2(1991); -console.log(age); +let rep = 1; //should create it outside and before the loop +while (rep <= 10) { + console.log(rep); + rep++; +} diff --git a/NOTES b/NOTES index e8187f1ce6..c263cf7347 100644 --- a/NOTES +++ b/NOTES @@ -66,7 +66,7 @@ console.log(I like to drink ${age >= 18 ? 'wine' : 'water'}) -//////FUNCTIONS FUNCTIONS FUNCTIONS FUNCTIONS ////// +//////FUNCTIONS FUNCTIONS FUNCTIONS FUNCTIONS FUNCTIONS FUNCTIONS FUNCTIONS FUNCTIONS////// //CREATE A FUNCTION (this way you can call this function even before declaring it) function logger(name) { @@ -89,18 +89,138 @@ console.log(age2) // 3 types tgether + function calcAge(birthyear){ return 2037 - birthyear; } + const calcAge = function (birthyear){ return 2037 - birthyear; } + const calcAge = birthyear => 2037 - birthyear; +////// ARRAYS ARRAYS ARRAYS ARRAYS ARRAYS ARRAYS ARRAYS ARRAYS ARRAYS ARRAYS ARRAYS ARRAYS ////// + +const numbers = [1,2,3,4] + +const years = new Array(1,2,3,4); //creation of new array using function + +const length = years.length // get the length of an array + +//ARRAY METHODS + +years.push(2024) // adds an element to the array +years.unshift(1995) // adds an element at the beggining of the array +years.pop() // removes the last element of an array +years.shift() // removes the first element of an array + +years.indexOf(2024) // returns the index of the searched element, if not, returns -1 + +years.includes(2024) // returns a bollean value + + +//////OBJECTS OBJECTS OBJECTS OBJECTS OBJECTS OBJECTS OBJECTS OBJECTS OBJECTS OBJECTS ////// + +const jonas = { + firstname : 'jonas' + lastname : 'shemd' + age : 2037-1991 + job : 'teacher' +} + +jonas.lastname //returns shemd, the value of the key +jonas['lastname'] // returns shemd, but to be used in functions since you can insert into [ ] for example : +const nameKey = 'Name' +console.log(jonas['first'+nameKey]) + +jonas.location = 'Portugal'; // adding new keys/values to the object +jonas['location2'] = 'France'; // adding new keys/values to the object + + + +const jonas = { + firstname : 'Jonas', + lastname : 'Shmed', + calcAge : function (birthyear){ + return 2037-birthyear + } +}; +console.log(jonas.calcAge(1991)); // dot method +console.log(jonas["calcAge"](1991)); //bracket method + +//in the next example we use this that references the object itself +const jonas = { + firstname : 'Jonas', + lastname : 'Shmed', + birthyear : '1991', + calcAge : function (){ + console.log(this) // just to see the objec, no need to write + return 2037 - this.birthyear //this applies to jonas object === this + } +}; +console.log(jonas.calcAge()); + +//here we will store the result of a function inside of a keyword age +const jonas = { + firstname : 'Jonas', + lastname : 'Shmed', + birthyear : '1991', + + calcAge : function (){ // function that calculates the age + + this.age = 2037 - this.birthyear //calculating the age and storing it in this.age + + return this.age + } +}; +console.log(jonas.calcAge()); // when we call the function, the keyword age is created with its value, otherwise it doenst exist + + + +//////LOOPS LOOPS LOOPS LOOPS LOOPS LOOPS LOOPS LOOPS LOOPS LOOPS ////// + +//FOR LOOP + +//loop that goes from 1 to 10 +for (let rep = 1; rep <= 10; rep++) { + console.log(rep); +} + +for(let i = 0 ; i < years.length ;i++) // tip : no need to use -1 since we use smaller operator + +//CONTINUE + +for (let rep = 1; rep <= 10; rep++) { + if (rep === 3) continue; + console.log(rep); +} + +//BREAK +for (let rep = 1; rep <= 10; rep++) { + if (rep === 3) break; + console.log(rep); +} + +//LOOPING BACKWARDS + +for (let i = myarray.length - 1; i>=0; i--){ + console.log(i) +} + +//WHILE LOOP + +let rep = 1 //should create it outside and before the loop +while (rep <= 10){ + console.log(rep); + rep++ +} + + From a187d913ed6534033e5f90fcc9dd42f1d8dd852f Mon Sep 17 00:00:00 2001 From: BGDNbgdn Date: Thu, 1 Aug 2024 00:13:30 +0200 Subject: [PATCH 5/6] updt --- 03-Developer-Skills/starter/script.js | 3 +-- NOTES | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/03-Developer-Skills/starter/script.js b/03-Developer-Skills/starter/script.js index 939b2a2446..4952f940a6 100644 --- a/03-Developer-Skills/starter/script.js +++ b/03-Developer-Skills/starter/script.js @@ -1,3 +1,2 @@ // Remember, we're gonna use strict mode in all scripts now! -'use strict'; - +"use strict"; diff --git a/NOTES b/NOTES index c263cf7347..5288e85905 100644 --- a/NOTES +++ b/NOTES @@ -217,7 +217,6 @@ for (let i = myarray.length - 1; i>=0; i--){ let rep = 1 //should create it outside and before the loop while (rep <= 10){ console.log(rep); - rep++ } @@ -237,6 +236,8 @@ while (rep <= 10){ + + From 94fb13494d6a502f0927933c5f98d3d8c141ab8d Mon Sep 17 00:00:00 2001 From: BGDNbgdn Date: Thu, 1 Aug 2024 00:17:03 +0200 Subject: [PATCH 6/6] updt --- 02-Fundamentals-Part-2/final/index.html | 54 ++++++++++++------------- 02-Fundamentals-Part-2/final/script.js | 2 +- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/02-Fundamentals-Part-2/final/index.html b/02-Fundamentals-Part-2/final/index.html index ee4909e282..5b4e7e726f 100755 --- a/02-Fundamentals-Part-2/final/index.html +++ b/02-Fundamentals-Part-2/final/index.html @@ -1,30 +1,30 @@ - - - - - JavaScript Fundamentals – Part 2 - - - -

JavaScript Fundamentals – Part 2

- - + + + + + JavaScript Fundamentals – Part 2 + + + +

JavaScript Fundamentals – Part 2

+ + diff --git a/02-Fundamentals-Part-2/final/script.js b/02-Fundamentals-Part-2/final/script.js index 8cee2087f7..bed4b98c68 100755 --- a/02-Fundamentals-Part-2/final/script.js +++ b/02-Fundamentals-Part-2/final/script.js @@ -1,4 +1,4 @@ -'use strict'; +"use strict"; /* ///////////////////////////////////////