This commit is contained in:
2024-09-21 11:10:25 +02:00
parent f6718afb32
commit 02cf9667f8
3 changed files with 125 additions and 1 deletions

View File

@ -97,4 +97,23 @@ let total = numberok.reduce(summa) //reduce()
console.log(total)
//https://youtu.be/lfmg-EJ8gm4?feature=shared&t=17107
//https://youtu.be/lfmg-EJ8gm4?feature=shared&t=17107
//Funcion Expressions
const hello = function(){
console.log("HELLO");
}
hello();
setTimeout(function(){
console.log("HOLA");
}, 3000);
//Arrow functions
const squaros = numberok.map((element) => Math.pow(element, 2));

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

View File

@ -0,0 +1,92 @@
//my first objectsű
const person = {
firstname: "Spongebob",
lastname: "Squarepants",
age: 30,
isemployed: true,
sayHello: function(){
console.log("HELOOOOOOO Im sponge!")
},
sayBye : () => console.log("BBBBYYEEEEEEEEEE!!!")
};
console.log(person.age);
console.log(person.firstname);
console.log(person.lastname);
person.sayHello();
person.sayBye();
//The "this" keyword!!!
const person2 = {
firstname: "Spongebob",
lastname: "Squarepants",
age: 30,
isemployed: true,
sayHello: function(){
console.log(`HELOOOOOOO I am ${this.firstname}!`)
},
sayBye : () => console.log(`BBBBYYEEEEEEEEEE I was ${this.firstname}`), // "this" CANT BE USED WITH ARROW FUNCTIONT!!!!
sayBye1 : () => console.log(`BBBBYYEEEEEEEEEE I was ${person2.firstname}`),
sayBye2 : () => console.log(`BBBBYYEEEEEEEEEE I was ${firstname}`), //WRONG!!!!!!!!
};
person2.sayHello();
person2.sayBye();
person2.sayBye1();
//person2.sayBye2();
function car(make, model, year, color){
this.make = make,
this.model = model,
this.year = year,
this.color = color,
this.drive = function(){
console.log(`You drive a ${this.make}!!`)
}
};
const car1 = new car("Tesla", "Y", 2015, "black");
const car2 = new car("Ford", "Mustang", 2020, "red");
console.log(car1.color);
const carList = []; //ObjectArray
carList.push(car1);
carList.push(car2);
console.log(carList);
carList[0].drive();
//CLASSES!!!!!!!!!!
class Products{
static tax = 1.27;
constructor(name, price){
this.name = name;
this.price = price;
}
displayProduct(){
console.log(`Product name: ${this.name}`);
}
displayPrice(){
console.log(`Theprice: ${this.price}`);
}
calculateTotal(){
console.log(`The taxed price will be: ${this.price * Products.tax}`);
}
}
const shirt = new Products("Shirt", 19.99);
const pants = new Products("Pants", 22.50);
const underwear = new Products("Underwear", 122.50);
underwear.displayProduct();
underwear.displayPrice();
underwear.calculateTotal();
//https://youtu.be/lfmg-EJ8gm4?si=KJ_EBH2FxCEtonyR&t=19910