Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>x100 Times Tables</title>
- <style>
- div {
- text-align:center;
- }
- body {
- background-color: black;
- }
- body,td,th {
- color: rgba(255,255,255,1);
- }
- </style>
- </head>
- <body>
- <div><h1>Press Any Key to Start</h1>
- <textarea style="height: 500px;" id="out"></textarea>
- <h3>See your favorite number up to x100!</h3></div>
- <script>
- var out = document.getElementById("out");
- var input = 0;
- window.addEventListener("keyup", function(e) {
- out.innerHTML = "";
- if (e.which == 82) {
- input = Math.floor(Math.random() * 1000);
- } else {
- input = prompt("What number?");
- }
- if (isNaN(input)) {
- out.innerHTML = "Input must only consist of numbers.";
- } else if (input == "") {
- out.innerHTML = "Input cannot be blank.";
- } else if (input == 0) {
- out.innerHTML = "Anything Multiplied by ZERO is ZERO.";
- } else if (input == null) {
- out.innerHTML = "Hitting Cancel won't do the trick. Please enter a value.";
- } else {
- for (var i = 1; i <= 100; i++) {
- out.innerHTML += input + " x ";
- if (i < 100) { out.innerHTML += " "; }
- if (i < 10) { out.innerHTML += " "; }
- out.innerHTML += i + " = ";
- if (input * i < 10000) { out.innerHTML += " "; }
- if (input * i < 1000) { out.innerHTML += " "; }
- if (input * i < 100) { out.innerHTML += " "; }
- if (input * i < 10) { out.innerHTML += " "; }
- out.innerHTML += (input * i) + "\n";
- }
- }
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement