0004 added[hypotenuseCalculator, counter, randomNumberGeneration]
This commit is contained in:
10
js/calcHypotenuse.js
Normal file
10
js/calcHypotenuse.js
Normal file
@@ -0,0 +1,10 @@
|
||||
//https://youtu.be/8dWL3wF_OMw?t=2213
|
||||
//Calculate hypotenuse on click of Submit-button.
|
||||
document.getElementById("calcHypotenuseButton").onclick = function() {
|
||||
let a = document.getElementById("sideAVal").value;
|
||||
let b = document.getElementById("sideBVal").value;
|
||||
let c;
|
||||
|
||||
c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2));
|
||||
document.getElementById("hypotenuse").innerHTML = "Hypotenuse: " + c;
|
||||
}
|
||||
19
js/count.js
Normal file
19
js/count.js
Normal file
@@ -0,0 +1,19 @@
|
||||
//Bro codes approach, probably better, since transforming less.
|
||||
|
||||
let count = 0;
|
||||
|
||||
document.getElementById("countDownButton").onclick = function() {
|
||||
count--;
|
||||
document.getElementById("counter").innerHTML = count;
|
||||
}
|
||||
|
||||
document.getElementById("resetButton").onclick = function() {
|
||||
count = 0;
|
||||
document.getElementById("counter").innerHTML = count;
|
||||
}
|
||||
|
||||
document.getElementById("countUpButton").onclick = function() {
|
||||
let i = Number.parseInt(document.getElementById("counter").innerHTML);
|
||||
count++;
|
||||
document.getElementById("counter").innerHTML = count;
|
||||
}
|
||||
17
js/counter.js
Normal file
17
js/counter.js
Normal file
@@ -0,0 +1,17 @@
|
||||
//My approach
|
||||
|
||||
document.getElementById("countDownButton").onclick = function() {
|
||||
let i = Number.parseInt(document.getElementById("counter").innerHTML);
|
||||
i--;
|
||||
document.getElementById("counter").innerHTML = i;
|
||||
}
|
||||
|
||||
document.getElementById("resetButton").onclick = function() {
|
||||
document.getElementById("counter").innerHTML = 0;
|
||||
}
|
||||
|
||||
document.getElementById("countUpButton").onclick = function() {
|
||||
let i = Number.parseInt(document.getElementById("counter").innerHTML);
|
||||
i++;
|
||||
document.getElementById("counter").innerHTML = i;
|
||||
}
|
||||
8
js/randomNumberGeneration.js
Normal file
8
js/randomNumberGeneration.js
Normal file
@@ -0,0 +1,8 @@
|
||||
//Generates semi random number between 1 and 6.
|
||||
let a = Math.floor(Math.random() * 6) + 1;
|
||||
|
||||
document.getElementById("roll").onclick = function() {
|
||||
document.getElementById("xLabel").innerHTML = Math.floor(Math.random() * 6) + 1;
|
||||
document.getElementById("yLabel").innerHTML = Math.floor(Math.random() * 6) + 1;
|
||||
document.getElementById("zLabel").innerHTML = Math.floor(Math.random() * 6) + 1;
|
||||
}
|
||||
Reference in New Issue
Block a user