From 31b6032aafaba43b0f03daa1515a82d9c155dd8b Mon Sep 17 00:00:00 2001 From: burhan1997 Date: Mon, 19 Feb 2024 23:16:11 +0100 Subject: [PATCH 01/11] linking a javascript file --- 01-Fundamentals-Part-1/starter/index.html | 2 ++ 01-Fundamentals-Part-1/starter/script.js | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 01-Fundamentals-Part-1/starter/script.js diff --git a/01-Fundamentals-Part-1/starter/index.html b/01-Fundamentals-Part-1/starter/index.html index 59529c7923..f44acb556b 100755 --- a/01-Fundamentals-Part-1/starter/index.html +++ b/01-Fundamentals-Part-1/starter/index.html @@ -25,5 +25,7 @@

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..6030307167 --- /dev/null +++ b/01-Fundamentals-Part-1/starter/script.js @@ -0,0 +1,4 @@ +let js = 'amazing'; +if (js === 'amazing') alert('Javascript is FUN!'); + +console.log(40 + 8 + 23 - 10); \ No newline at end of file From b994da6bb67a6f4b2cc251d6f109c164b17cf9a4 Mon Sep 17 00:00:00 2001 From: burhan1997 Date: Mon, 19 Feb 2024 23:41:38 +0100 Subject: [PATCH 02/11] naming conventions --- 01-Fundamentals-Part-1/starter/script.js | 25 ++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/01-Fundamentals-Part-1/starter/script.js b/01-Fundamentals-Part-1/starter/script.js index 6030307167..e9e9da1a34 100644 --- a/01-Fundamentals-Part-1/starter/script.js +++ b/01-Fundamentals-Part-1/starter/script.js @@ -1,4 +1,25 @@ let js = 'amazing'; -if (js === 'amazing') alert('Javascript is FUN!'); +console.log(40 + 8 + 23 - 10); -console.log(40 + 8 + 23 - 10); \ No newline at end of file +console.log('Jonas'); +console.log(23); + +let firstName = "Matilda"; + +console.log(firstName); +console.log(firstName); +console.log(firstName); + +let jonas_matilda = "JM"; +let $function = 27; + +let person = 'jonas'; +let PI = 3.1415; + +let myFirstJob = 'Programmer'; +let myCurrentJob = 'Teacher'; + +let job1 = 'programmer'; +let job2 = 'teacher'; + +console.log(myFirstJob); \ No newline at end of file From fb62c7cf144ce21eef01eeccc1cc6e2ab08faae5 Mon Sep 17 00:00:00 2001 From: burhan1997 Date: Tue, 20 Feb 2024 00:26:30 +0100 Subject: [PATCH 03/11] dataTypes are revised --- 01-Fundamentals-Part-1/starter/script.js | 25 +++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/01-Fundamentals-Part-1/starter/script.js b/01-Fundamentals-Part-1/starter/script.js index e9e9da1a34..39d745c8d3 100644 --- a/01-Fundamentals-Part-1/starter/script.js +++ b/01-Fundamentals-Part-1/starter/script.js @@ -1,3 +1,4 @@ +/* let js = 'amazing'; console.log(40 + 8 + 23 - 10); @@ -10,6 +11,7 @@ console.log(firstName); console.log(firstName); console.log(firstName); +// Variable name conventions let jonas_matilda = "JM"; let $function = 27; @@ -22,4 +24,25 @@ let myCurrentJob = 'Teacher'; let job1 = 'programmer'; let job2 = 'teacher'; -console.log(myFirstJob); \ No newline at end of file +console.log(myFirstJob); +*/ + +let javascriptIsFun = true; +console.log(javascriptIsFun); + +console.log(typeof true); +console.log(typeof javascriptIsFun); +console.log(typeof 23); +console.log(typeof "Jonas"); + +javascriptIsFun = "YES!"; +console.log(typeof javascriptIsFun); + +let year; +console.log(year); +console.log(typeof year); + +year = 1991; +console.log(typeof year); + +console.log(typeof null); \ No newline at end of file From f7e78c7204e434982822bb5697c3d5fd848badd1 Mon Sep 17 00:00:00 2001 From: burhan1997 Date: Tue, 20 Feb 2024 00:31:41 +0100 Subject: [PATCH 04/11] dataTypes are done --- 01-Fundamentals-Part-1/starter/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01-Fundamentals-Part-1/starter/script.js b/01-Fundamentals-Part-1/starter/script.js index 39d745c8d3..4e3a8b17a8 100644 --- a/01-Fundamentals-Part-1/starter/script.js +++ b/01-Fundamentals-Part-1/starter/script.js @@ -45,4 +45,4 @@ console.log(typeof year); year = 1991; console.log(typeof year); -console.log(typeof null); \ No newline at end of file +console.log(typeof null); From 0ca1508fee4f71732d866c3194a125edc4e365ee Mon Sep 17 00:00:00 2001 From: burhan1997 Date: Fri, 23 Feb 2024 21:13:53 +0100 Subject: [PATCH 05/11] let, const and var --- 01-Fundamentals-Part-1/starter/script.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/01-Fundamentals-Part-1/starter/script.js b/01-Fundamentals-Part-1/starter/script.js index 4e3a8b17a8..c3f64358cf 100644 --- a/01-Fundamentals-Part-1/starter/script.js +++ b/01-Fundamentals-Part-1/starter/script.js @@ -25,7 +25,7 @@ let job1 = 'programmer'; let job2 = 'teacher'; console.log(myFirstJob); -*/ + let javascriptIsFun = true; console.log(javascriptIsFun); @@ -46,3 +46,19 @@ year = 1991; console.log(typeof year); console.log(typeof null); + +*/ + +let age= 30; +age = 31; + +const birthYear = 1991; +//birthYear = 1990; + +const job; + +var job = 'programmer'; +job = 'teacher'; + +lastName = 'Schmedtmann'; +console.log(lastName); \ No newline at end of file From a13f3708acb389484097b74f69547e4c77d48dbe Mon Sep 17 00:00:00 2001 From: burhan1997 Date: Fri, 23 Feb 2024 21:39:29 +0100 Subject: [PATCH 06/11] Basic Operators --- 01-Fundamentals-Part-1/starter/script.js | 32 +++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/01-Fundamentals-Part-1/starter/script.js b/01-Fundamentals-Part-1/starter/script.js index c3f64358cf..e5c9ac4144 100644 --- a/01-Fundamentals-Part-1/starter/script.js +++ b/01-Fundamentals-Part-1/starter/script.js @@ -61,4 +61,34 @@ var job = 'programmer'; job = 'teacher'; lastName = 'Schmedtmann'; -console.log(lastName); \ No newline at end of file +console.log(lastName); + +//Math operators +const now = 2037; +const ageJonas = now - 1991; +const ageSarah = now - 2018; +console.log(ageJonas, ageSarah); + +console.log(ageJonas * 2, ageJonas / 10, 2 ** 3); +// 2 ** 3 means 2 to the power of 3 = 2*2*2 + +const firstName = 'Jonas'; +const lastName = 'Schmedtmann'; +console.log(firstName + ' ' + lastName); + + +//Assignment operators +let x = 10 + 5; // 15 +x += 10; // x = x + 10 = 25 +x *= 4; // x = x * 4 = 100 +x++; // x = x + 1 +x--; +console.log(x); + +// Comparison operators +console.log(ageJonas > ageSarah); // >, <, >=, <= +console.log(ageSarah >= 18); + +const isFullAge = ageSarah >= 18; + +console.log(now - 1991 > now - 2018); \ No newline at end of file From 030afbe60d54d0ba8e35c6734d7834556f5ef573 Mon Sep 17 00:00:00 2001 From: burhan1997 Date: Fri, 23 Feb 2024 22:12:57 +0100 Subject: [PATCH 07/11] Operator Presedence --- 01-Fundamentals-Part-1/starter/script.js | 26 +++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/01-Fundamentals-Part-1/starter/script.js b/01-Fundamentals-Part-1/starter/script.js index e5c9ac4144..2d9f0933e1 100644 --- a/01-Fundamentals-Part-1/starter/script.js +++ b/01-Fundamentals-Part-1/starter/script.js @@ -47,7 +47,7 @@ console.log(typeof year); console.log(typeof null); -*/ + let age= 30; age = 31; @@ -62,7 +62,7 @@ job = 'teacher'; lastName = 'Schmedtmann'; console.log(lastName); - +//Basic Operators //Math operators const now = 2037; const ageJonas = now - 1991; @@ -91,4 +91,24 @@ console.log(ageSarah >= 18); const isFullAge = ageSarah >= 18; -console.log(now - 1991 > now - 2018); \ No newline at end of file +console.log(now - 1991 > now - 2018); +*/ + +//Operator Precedence +const now = 2037; +const ageJonas = now - 1991; +const ageSarah = now - 2018; + +console.log(now - 1991 > now - 2018); + +console.log(25 - 10 - 5); + +let x, y; +x = y = 25 - 10 - 5; // x = y = 10 +console.log(x , y); + +const averageAge = (ageJonas + ageSarah) / 2; +console.log(ageJonas, ageSarah,averageAge); + + + From 4a2b83c5da7f2c932c94d16d5ad58617bcab1cf5 Mon Sep 17 00:00:00 2001 From: burhan1997 Date: Fri, 23 Feb 2024 22:36:31 +0100 Subject: [PATCH 08/11] coding challange is added --- 01-Fundamentals-Part-1/coding_challenge_1.js | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 01-Fundamentals-Part-1/coding_challenge_1.js diff --git a/01-Fundamentals-Part-1/coding_challenge_1.js b/01-Fundamentals-Part-1/coding_challenge_1.js new file mode 100644 index 0000000000..5aef1a8f42 --- /dev/null +++ b/01-Fundamentals-Part-1/coding_challenge_1.js @@ -0,0 +1,30 @@ +/* +Mark and John are trying to compare their BMI (Body Mass Index), which is +calculated using the formula: +BMI = mass / height ** 2 = mass / (height * height) (mass in kg +and height in meter). +Your tasks: +1. Store Mark's and John's mass and height in variables +2. Calculate both their BMIs using the formula (you can even implement both +versions) +3. Create a Boolean variable 'markHigherBMI' containing information about +whether Mark has a higher BMI than John. +Test data: +§ Data 1: Marks weights 78 kg and is 1.69 m tall. John weights 92 kg and is 1.95 +m tall. +§ Data 2: Marks weights 95 kg and is 1.88 m tall. John weights 85 kg and is 1.76 +m tall. +*/ +let massMark = 78; +let massJohn = 95; + +let weightMark = 1.69; +let weightJohn = 1.88; + +let bmiMark = massMark / (weightMark ** 2); +let bmiJohn = massJohn / (weightJohn ** 2); +console.log(bmiJohn); +console.log(bmiMark); +let markHigherBMI = bmiJohn < bmiMark; + + From 27eff34de9fb9ebcebcbbe1e895a417ec3a21adf Mon Sep 17 00:00:00 2001 From: burhan1997 Date: Fri, 23 Feb 2024 22:48:57 +0100 Subject: [PATCH 09/11] coding challange is remade --- 01-Fundamentals-Part-1/coding_challenge_1.js | 35 +++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/01-Fundamentals-Part-1/coding_challenge_1.js b/01-Fundamentals-Part-1/coding_challenge_1.js index 5aef1a8f42..224e01b192 100644 --- a/01-Fundamentals-Part-1/coding_challenge_1.js +++ b/01-Fundamentals-Part-1/coding_challenge_1.js @@ -15,16 +15,33 @@ m tall. § Data 2: Marks weights 95 kg and is 1.88 m tall. John weights 85 kg and is 1.76 m tall. */ -let massMark = 78; -let massJohn = 95; -let weightMark = 1.69; -let weightJohn = 1.88; +// let massMark = 78; +// let massJohn = 92; -let bmiMark = massMark / (weightMark ** 2); -let bmiJohn = massJohn / (weightJohn ** 2); -console.log(bmiJohn); -console.log(bmiMark); -let markHigherBMI = bmiJohn < bmiMark; +// let heightMark = 1.69; +// let heightJohn = 1.95; +// let bmiMark = massMark / (heightMark ** 2); +// let bmiJohn = massJohn / (heightJohn ** 2); +// console.log(bmiJohn); +// console.log(bmiMark); + +// let markHigherBMI = bmiMark < bmiJohn; + +// console.log(bmiMark, bmiJohn, markHigherBMI); + + +let massMark = 95; +let massJohn = 85; + +let heightMark = 1.88; +let heightJohn = 1.76; + +let bmiMark = massMark / heightMark ** 2; +let bmiJohn = massJohn / heightJohn ** 2; + +let markHigherBMI = bmiMark < bmiJohn; + +console.log(bmiMark, bmiJohn, markHigherBMI); \ No newline at end of file From b4e10f3ba83c2b8a8c62d86eac881ba6882db746 Mon Sep 17 00:00:00 2001 From: burhan1997 Date: Tue, 27 Feb 2024 16:12:55 +0100 Subject: [PATCH 10/11] Strings and Template Literals --- 01-Fundamentals-Part-1/starter/script.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/01-Fundamentals-Part-1/starter/script.js b/01-Fundamentals-Part-1/starter/script.js index 2d9f0933e1..413d4f2d27 100644 --- a/01-Fundamentals-Part-1/starter/script.js +++ b/01-Fundamentals-Part-1/starter/script.js @@ -92,7 +92,7 @@ console.log(ageSarah >= 18); const isFullAge = ageSarah >= 18; console.log(now - 1991 > now - 2018); -*/ + //Operator Precedence const now = 2037; @@ -109,6 +109,26 @@ console.log(x , y); const averageAge = (ageJonas + ageSarah) / 2; console.log(ageJonas, ageSarah,averageAge); +*/ + +//Strings and template literals +const firstName = 'Jonas'; +const job = 'teacher'; +const birthYear = 1991; +const year = 2037; + +const jonas = "I'm " + firstName + ', a ' + (year - birthYear) + ' years old' + job + '!'; +console.log(jonas); + +const jonasNew = `I'm ${firstName}, a ${year - birthYear} year old ${job}`; +console.log(jonasNew); +console.log(`Just a regular string...`); +console.log('String with \n\ +multiple \n\ +lines'); +console.log(`String +multiple +lines`); \ No newline at end of file From 57ef199182ad744e704d1c6451e7384082310b4e Mon Sep 17 00:00:00 2001 From: burhan1997 Date: Tue, 27 Feb 2024 16:39:11 +0100 Subject: [PATCH 11/11] Taking Decisions: if / else Statements --- 01-Fundamentals-Part-1/starter/script.js | 29 ++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/01-Fundamentals-Part-1/starter/script.js b/01-Fundamentals-Part-1/starter/script.js index 413d4f2d27..7c86759f6d 100644 --- a/01-Fundamentals-Part-1/starter/script.js +++ b/01-Fundamentals-Part-1/starter/script.js @@ -109,7 +109,7 @@ console.log(x , y); const averageAge = (ageJonas + ageSarah) / 2; console.log(ageJonas, ageSarah,averageAge); -*/ + //Strings and template literals const firstName = 'Jonas'; @@ -131,4 +131,29 @@ lines'); console.log(`String multiple -lines`); \ No newline at end of file +lines`); +*/ + +// Taking decisions with if/else statements +const age = 15; + + +if(age >= 18) { + console.log('Sarah can start driving license🥵') +} else { + const yearsLeft = 18 - age; + console.log(`Sarah is too young. wait another ${yearsLeft} years :)`); +}; + + +const birthYear +const birthYear = 1998; + +let century; + +if(birthYear <= 2000){ + century = 20; +} else { + century = 21; +} +console.log(century); \ No newline at end of file