From a6e71bf9aa1094e902ea502d240b0e861d6e1ff8 Mon Sep 17 00:00:00 2001 From: Kilokem Date: Thu, 19 Sep 2024 20:00:40 +0200 Subject: [PATCH] StringsAndAll --- ConditionalConquest/index.html | 50 +++++++++++++++++++- ConditionalConquest/script.js | 85 +++++++++++++++++++++++++++++++++- 2 files changed, 133 insertions(+), 2 deletions(-) diff --git a/ConditionalConquest/index.html b/ConditionalConquest/index.html index eb5478f..5c0dfe6 100644 --- a/ConditionalConquest/index.html +++ b/ConditionalConquest/index.html @@ -6,8 +6,56 @@ Another Junkie site! - +
+

Which one is bigger?

+ + + + + +

The stick of TRUTH

+
+
+

CHECKED!

+ + +
+
+

Radio

+ +
+ +
+ +
+ +
+
+

Ternary operations

+ +
+ +
+ +
+
+ + + +
+

Days of the week

+ + +

+
+ +
+

String manipulation

+ + +

+
\ No newline at end of file diff --git a/ConditionalConquest/script.js b/ConditionalConquest/script.js index 51c6887..eb5dd20 100644 --- a/ConditionalConquest/script.js +++ b/ConditionalConquest/script.js @@ -1,3 +1,86 @@ document.addEventListener("DOMContentLoaded", function() { - + document.getElementById("TheAnsweer").onclick = function(){ + let a = Number(document.getElementById("numberaa").textContent); + let b = Number(document.getElementById("numberba").textContent); + if(a > b){ + document.getElementById("answera").textContent = "Number a is bigger!!!!"; + }else{ + document.getElementById("answera").textContent = "Number b is bigger!!!!"; + } + }; + + document.getElementById("theboxoftruth").onchange = function(){ + let a = document.getElementById("theboxoftruth").checked; + if(a == true){ + document.getElementById("thevalueoftruth").textContent = "CHECKED!"; + }else{ + document.getElementById("thevalueoftruth").textContent = "UNCHECKED!"; + } + }; + + document.getElementById("radiosubmitter").onclick = function(){ + document.getElementById("cardiradiolab").textContent = document.getElementById("cardiradio").checked; + document.getElementById("cardtradiolab").textContent = document.getElementById("cardtradio").checked; + document.getElementById("cardhradiolab").textContent = document.getElementById("cardhradio").checked; + }; + + + document.getElementById("daysliderer").onchange = function(){ //The switch + let day = "asd"; + switch(Number(document.getElementById("daysliderer").value)){ + case 0: + day = "Monday"; + break; + case 1: + day = "Tuesday"; + break + case 2: + day = "Wednesday"; + break + case 3: + day = "Thursday"; + break + case 4: + day = "Friday"; + break + case 5: + day = "Saturday"; + break + case 6: + day = "Sunday"; + break + } + document.getElementById("daysoftheweek").textContent = day; + }; + + document.getElementById("themodifierinputtext").onchange = function(){ //Text mods text.trim() will reomve all the widespaces before and after the string + let text = document.getElementById("themodifierinputtext").value; + let out = document.getElementById("modifiedoutput"); + if(Boolean(text)){ + out.innerHTML = "The first letter: " + text.charAt(0) + "
"; + out.innerHTML += "The last letter: " + text.charAt(text.length - 1) + "
"; + out.innerHTML += "First location of the letter 's': " + text.indexOf('s') + "
"; + out.innerHTML += "Last location of the letter 's': " + text.lastIndexOf('s') + "
"; + out.innerHTML += "Uppercase: " + text.toUpperCase() + "
"; + out.innerHTML += "Lovercase: " + text.toLowerCase() + "
"; + out.innerHTML += "Repeate: " + text.repeat(3) + "
"; + out.innerHTML += "Does it starts with 'Awesome': " + text.startsWith("Awesome") + "
"; + out.innerHTML += "Does it ends with 'me': " + text.startsWith("me") + "
"; + out.innerHTML += "Replace letter 'a' with 'o': " + text.replaceAll("a", "o") + "
"; + out.innerHTML += "Fill till 15 with 'o': " + text.padStart(15, "o") + "
"; + out.innerHTML += "Fill till 15 with 'o': " + text.padEnd(15, "o") + "
"; + }else{ + out.innerHTML = ""; + } + }; + + }); + +function RadioChanged(){ //ternary operator statement ? true : false + document.getElementById("checkedone").textContent = + document.getElementById("cardiradiott").checked ? "Card1" : + document.getElementById("cardiradiott2").checked ? "Card2" : + document.getElementById("cardiradiott3").checked ? "Card3" : + "Not this!"; +};