NextStage!

This commit is contained in:
2024-09-20 09:47:23 +02:00
parent c31f1b9686
commit 7fa0b67119
4 changed files with 76 additions and 6 deletions

View File

@ -40,7 +40,6 @@
<label for="cardhradio">Card3</label> <label for="cardhradio">Card3</label>
<input type="radio" name="rad1" id="cardiradiott3" onchange=RadioChanged()><br> <input type="radio" name="rad1" id="cardiradiott3" onchange=RadioChanged()><br>
<label for="" id="checkedone"></label><br> <label for="" id="checkedone"></label><br>
<input type="button" value="Submit!" id="radiosubmitter">
</div> </div>
<div> <div>
@ -60,8 +59,22 @@
<div> <div>
<h1>MethodChaining</h1> <h1>MethodChaining</h1>
<input type="button" value="BEGIN THE QUESTIONING!!!" id="MethodChaining"> <input type="button" value="BEGIN THE QUESTIONING!!!" id="MethodChaining">
<p id="capitalisedletter">Your name with capital first letter: </p>
</div> </div>
<div>
<h1>PIRAMIDTIME!!!!</h1>
<input type="button" value="PIRAMIDTIME!" id="beginpiramid">
<p id="piramidtime"></p>
</div>
<div>
<h1>NUMBER Guesser!</h1>
<p>Guess the number between 10 and 25!</p>
<input type="button" value="Begin!" id="Guesserbeginer">
</div>
<script src="script.js"></script> <script src="script.js"></script>
</body> </body>
</html> </html>

View File

@ -75,13 +75,39 @@ document.addEventListener("DOMContentLoaded", function() {
} }
}; };
document.getElementById("MethodChaining").onclick = function(){ document.getElementById("MethodChaining").onclick = function(){ //Method chaining
let name = window.prompt("Please enter your gorgeous name!!"); let name = null;
username = username.strim() while (name === "" || name === null) { // Strict operators: === and !== compares the value and the type while single == and != just compares the value
} name = window.prompt("Please enter your gorgeous name!! THERES NO ESCAPE!");
}
name = name.trim();
document.getElementById("capitalisedletter").innerHTML += name.charAt(0).toUpperCase() + name.slice(1)
};
document.getElementById("beginpiramid").onclick = function() {
let out = document.getElementById("piramidtime");
if(out.innerHTML === ""){
for (let i = 0; i < 30; i++) {
for(let j = i; j < 15; j++){
out.innerHTML += "V";
for (let ii = 0; ii < i; ii++) {
out.innerHTML += "A";
}
}
out.innerHTML += "<br/>";
}
}else out.innerHTML = "";
};
document.getElementById("Guesserbeginer").onclick = function(){
const min = 10, max = 24;
random = Math.trunc(Math.random()*(max-min)) + min
do {
answer = window.prompt("Guess the number between 10 and 25!")
} while (random !== Number(answer) && answer !== "" && answer !== null);
random === Number(answer) ? alert("You guessed it!!!") : null;
};
}); });
function RadioChanged(){ //ternary operator statement ? true : false function RadioChanged(){ //ternary operator statement ? true : false
@ -92,4 +118,35 @@ function RadioChanged(){ //ternary operator statement ? true : false
"Not this!"; "Not this!";
}; };
//Messing with lists
let fruits = ["Apple", "Preal", "Plum", "Banana", "Orange"];
console.log(fruits);
console.log(fruits[2]);
fruits[0] = "Coconut";
fruits.push("Apple");
console.log(fruits);
fruits.pop();
console.log(fruits.length);
console.log(fruits);
for (let index = 0; index < fruits.length; index++) {
console.error("Fake warning!!! " + fruits[index]);
}
for(let item of fruits){
console.log(item);
}
fruits.sort();
console.log(fruits);
fruits.sort().reverse();
console.log(fruits);
//https://youtu.be/lfmg-EJ8gm4?si=I0Ugyw-qkk3VX8Rk&t=7429 //https://youtu.be/lfmg-EJ8gm4?si=I0Ugyw-qkk3VX8Rk&t=7429

0
FunctionalFun/index.html Normal file
View File

0
FunctionalFun/script.js Normal file
View File