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,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");