Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count commits #431

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 35 additions & 27 deletions 01-Fundamentals-Part-1/starter/index.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>JavaScript Fundamentals – Part 1</title>
<style>
body {
height: 100vh;
display: flex;
align-items: center;
background: linear-gradient(to top left, #28b487, #7dd56f);
}
h1 {
font-family: sans-serif;
font-size: 50px;
line-height: 1.3;
width: 100%;
padding: 30px;
text-align: center;
color: white;
}
</style>
</head>
<body>
<h1>JavaScript Fundamentals – Part 1</h1>
</body>
</html>

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>JavaScript Fundamentals - Part 1</title>
<style>
body {
height: 100vh;
display: flex;
align-items: center;
background: linear-gradient(to top left, #28b487, #7dd56f);
}

h1 {
font-family: sans-serif;
font-size: 50px;
line-height: 1.3;
width: 100%;
padding: 30px;
text-align: center;
color: white;
}
</style>


</head>

<body>
<h1>JavaScript Fundamentals - Part 1</h1>

<script src="script.js"></script>
</body>

</html>
4 changes: 4 additions & 0 deletions 01-Fundamentals-Part-1/starter/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const age = 23;
const drink = age >= 18 ? "wine" : "water";

console.log(`I like to drink ${age >= 18 ? "wine" : "water"}`);
54 changes: 27 additions & 27 deletions 02-Fundamentals-Part-2/final/index.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>JavaScript Fundamentals – Part 2</title>
<style>
body {
height: 100vh;
display: flex;
align-items: center;
background: linear-gradient(to top left, #28b487, #7dd56f);
}
h1 {
font-family: sans-serif;
font-size: 50px;
line-height: 1.3;
width: 100%;
padding: 30px;
text-align: center;
color: white;
}
</style>
</head>
<body>
<h1>JavaScript Fundamentals – Part 2</h1>
<script src="script.js"></script>
</body>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>JavaScript Fundamentals – Part 2</title>
<style>
body {
height: 100vh;
display: flex;
align-items: center;
background: linear-gradient(to top left, #28b487, #7dd56f);
}
h1 {
font-family: sans-serif;
font-size: 50px;
line-height: 1.3;
width: 100%;
padding: 30px;
text-align: center;
color: white;
}
</style>
</head>
<body>
<h1>JavaScript Fundamentals – Part 2</h1>
<script src="script.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion 02-Fundamentals-Part-2/final/script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
"use strict";

/*
///////////////////////////////////////
Expand Down
7 changes: 7 additions & 0 deletions 02-Fundamentals-Part-2/starter/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";

let rep = 1; //should create it outside and before the loop
while (rep <= 10) {
console.log(rep);
rep++;
}
3 changes: 1 addition & 2 deletions 03-Developer-Skills/starter/script.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
// Remember, we're gonna use strict mode in all scripts now!
'use strict';

"use strict";
243 changes: 243 additions & 0 deletions NOTES
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
console.log(typeof true);
// Gives the type of a variable


firstname = "Bogdan";
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


/* 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 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;



////// 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);
}