Absurd Random Number Generator
- Matthew Campbell
- Apr 4, 2023
- 1 min read
Absurd HTML, Java, CSS script that generates a random number. Check out how the script works below, and feel free to copy and embed it on your own website. This is purely for fun, but you never know, maybe it will have a use!
Test Here
Test Above
Code Below
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Random Calculation</title>
<style>
/* Add CSS styling here */
</style>
<script>
function calculateResult() {
// Get the current time
var date = new Date();
var hour = date.getHours();
// Generate a random number between 6 and 798
var randomNum = Math.floor(Math.random() * (798 - 6 + 1) + 6);
// Multiply the random number by the hour of the day
var result = randomNum * hour;
// If the hour is even, divide the result by a random number between 3 and 5
if (hour % 2 == 0) {
var divisor = Math.floor(Math.random() * (5 - 3 + 1) + 3);
result = result / divisor;
}
// Create three Date objects representing the current time in different time zones
var date1 = new Date().toLocaleString("en-US", {timeZone: "America/New_York"});
var date2 = new Date().toLocaleString("en-US", {timeZone: "Europe/London"});
var date3 = new Date().toLocaleString("en-US", {timeZone: "Asia/Tokyo"});
// Calculate the percentage of the result for each time zone
var percent1 = result * 0.25;
var percent2 = result * 0.50;
var percent3 = result * 0.25;
// Display the final result
document.getElementById("result").innerHTML = "Final result: " + result;
// Send the result to a server using HTTP
// (Code for sending HTTP request will depend on the specific requirements of your project)
}
</script>
</head>
<body>
<button onclick="calculateResult()">Click to Calculate</button>
<div id="result"></div>
</body>
</html>
Comments