Commit da3a8548 authored by ccottier's avatar ccottier

get your javascript fundamentals >>here<<

parents
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="text/javascript" src="myscript.js"></script>
</head>
<body id="bod">
<h1>unstoppable html</h1>
<script>
document.write("<h2>Am i a real element?</h2>")
const fun = function(personName, session) {
return "Hello " + personName + "! Welcome to " + session;
}('Pradeep','JavaScript');
document.write(fun);
</script>
</body>
</html>
\ No newline at end of file
//both html dom interactions and random JavaScript topics are in this file,
document.addEventListener("DOMContentLoaded", ()=> {
const body = document.getElementById("bod");
const div = document.createElement("div");
div.innerText = "What time is it?";
body.appendChild(div);
let currentTime;
const timeDiv = document.createElement("div");
body.appendChild(timeDiv);
setInterval(()=>{
currentTime = new Date();
const hours = currentTime.getUTCHours() - 5;
const mins = currentTime.getUTCMinutes();
const seconds = currentTime.getUTCSeconds();
timeDiv.innerText = `${ hours > 12 ? hours - 12 : hours}:${mins < 10 ? `0${mins}` : mins}:${seconds < 10 ? `0${seconds}` : seconds} CT`;
},1000);
//Just JS stuff below
function addingRecursion(...args){
if (args.length === 0) return 0;
return args[0] + addingRecursion(...args.slice(1));
}
console.log(addingRecursion(1,3,4,7,5,3));
function canHardly(num1,num2){
return num1 + (function(){return num2 ** 2;})();
}
console.log(canHardly(1,8));
function imGonnaReturnMyself(){
console.log("completing complex algo for self returnation")
return imGonnaReturnMyself;
}
const returned = imGonnaReturnMyself();
const counterFactory = () => {
let count = 0;
return (
() => {
count++;
console.log(count);
}
)
}
const counter1 = counterFactory();
counter1();
counter1();
if (2 == "2"){
let arr = [1785,2 % 5,34, 2 == "2"];
for (let el of arr){
console.log(el);
}
}
const a = 10;
switch (a) {
case 10:
console.log("I'm 10");
break;
case 21:
console.log("wow");
break;
case "10":
console.log("string>");
break;
}
})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment