RearangeClockMiniProjectAndOthers

This commit is contained in:
2024-10-10 18:01:24 +02:00
parent 182c614783
commit dacbb89950
22 changed files with 232 additions and 2 deletions

View File

@ -0,0 +1 @@
https://www.pexels.com/hu-hu/

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

View File

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Clock</title>
</head>
<style>
* {
padding: 0;
margin: 0;
border-width: 0;
}
.container {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
vertical-align: middle;
height: 100vh;
font-weight: bold;
font-size: 10ch;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
background-image: url("bgimg.jpg");
background-size: cover;
}
#clock {
color: white;
background-color: rgba(0, 0, 0, 30%);
}
</style>
<body>
<div class="container">
<h1 id="clock">00:00:00</h1>
</div>
<script src="clock.js"></script>
</body>
</html>

View File

@ -0,0 +1,12 @@
function updateClock(){
const time = new Date();
const hours = time.getHours().toString().padStart(2, "0");
const minutes = time.getMinutes().toString().padStart(2, "0");
const seconds = time.getSeconds().toString().padStart(2, "0");
const time_string = `${hours}:${minutes}:${seconds}`;
document.getElementById("clock").textContent = time_string;
}
updateClock();
setInterval(updateClock, 1000);

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tittle</title>
</head>
<body>
<h1>For every output check out the console!!!</h1>
<script src="script.js"></script>
</body>
</html>

View File

@ -0,0 +1,111 @@
//DESTRUCTING
const colors = ["red", "blue", "green", "black", "white"];
console.log(colors);
//swap
[colors[0], colors[2]] = [colors[2], colors[0]];
console.log(colors);
const [firstn, secondn, thirdn, ...restn] = colors;
console.log(firstn);
console.log(secondn);
console.log(thirdn);
console.log(restn);
const person1 = {
first : "Sponge",
last : "Squarepants",
age : 30,
job : "FryCook"
};
const person2 = {
first : "Patrick",
last : "Star",
age : 35,
};
const {first, last, age, job = "Unemployed"} = person2;
console.log(first);
console.log(last);
console.log(age);
console.log(job);
function DisplayPerson({first, last, age, job = "Unemployed"}){
console.log(`${first} ${last} age: ${age} is currently ${job}`);
}
DisplayPerson(person1);
DisplayPerson(person2);
//NESTED OBJECTS
const persona = {
fullName : "Spongebob Squarepants",
age : 30,
isStudent : true,
hobbies : ["Karate", "Danceing", "Cooking"],
address : {
street : "Some st",
city : "Bikkini bottom",
country : "In Water"
}
}
console.log(persona.fullName);
console.log(persona.age);
console.log(persona.isStudent);
console.log(persona.hobbies[0]);
console.log(persona.hobbies[1]);
console.log(persona.hobbies[2]);
console.log(persona.address.city);
persona.hobbies.forEach(element => {
console.log(element)
});
for(const item in persona.address){
console.log(persona.address[item])
}
class Person{
constructor(name, age, ...adres){
this.name = name;
this.age = age;
this.address = new Address(...adres);
}
}
class Address{
constructor(street, city, country){
this.street = street;
this.city = city;
this.country = country;
}
}
const p = new Person("Spongebob", 32, "sth st.", "Bikini bottm", "In tha ater");
console.log(p)
//SORTING
colors.sort();
console.log(colors)
const nums = [1,2,6,8,4,41,2,5,6,10,2,0,1,2,5,7,8,9,3,3,2,5,4,25,74,85,25,36,66,41,23,36]
console.log(nums.sort())
console.log(nums.sort((a, b) => a - b))
console.log(nums.sort((a, b) => b - a))
const people = [{name: "Sponge", age: 25, gpa: 5.2},
{name: "Patrick", age: 35, gpa: 3.5},
{name: "Sandy", age: 32, gpa: 4.7},
{name: "Sqidwards", age: 32, gpa: 14.7}];
console.log(people.sort((a, b) => a.age - b.age))
console.log(people.sort((a, b) => a.gpa - b.gpa))
console.log(people.sort().name)

View File

Before

Width:  |  Height:  |  Size: 556 KiB

After

Width:  |  Height:  |  Size: 556 KiB

View File

Before

Width:  |  Height:  |  Size: 460 KiB

After

Width:  |  Height:  |  Size: 460 KiB

View File

Before

Width:  |  Height:  |  Size: 172 KiB

After

Width:  |  Height:  |  Size: 172 KiB

View File

Before

Width:  |  Height:  |  Size: 268 KiB

After

Width:  |  Height:  |  Size: 268 KiB

View File

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 122 KiB

View File

Before

Width:  |  Height:  |  Size: 197 KiB

After

Width:  |  Height:  |  Size: 197 KiB

View File

@ -6,8 +6,7 @@
<title>Document</title>
</head>
<body>
<h1>For every output check out the console!!!</h1>
<script src="script.js"></script>
</body>
</html>

View File

@ -0,0 +1,12 @@
<!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>
<h1>For every output check out the console!!!</h1>
<script src="script.js"></script>
</body>
</html>

View File

@ -0,0 +1,45 @@
//DATE OBJECTS
//Date(year, month, day, hours, minutes, seconds, milliseconds)
const today = new Date();
console.log(today);
console.log(today.toLocaleDateString());
console.log(today.toLocaleTimeString());
console.log(today.toDateString());
console.log(today.toTimeString());
console.log(today.getTime());
//CLOSURES by using closures we can reuse a function without having to create a new one. And with this we an store variables safely.
function createCounter(){
let count = 0;
function increment(){
count++;
console.log(count);
}
function getCount(){
return count;
}
return {increment};
}
counter = createCounter();
counter.increment();
counter.increment();
counter.increment();
//SETTIMEOUT Note this function is not too precise!
function hello(){
console.log("HOLA");
}
setTimeout(hello, 3000); //It will delay the function by 3 seconds
setTimeout( function(){console.log("HOLA")}, 3000);
setTimeout(() => window.alert("HOLA"), 3000);
console.log("HOLA");