Commit d0ba5f83 authored by H-Graesberg's avatar H-Graesberg
Browse files

index file for running the randnumGen

parent 129798cb
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Random Number Generator</title>
<h2>How many values between 0 and 9 do you want to generate?</h2>
<input type="number" name="numberGenerate" placeholder="Values to generate" id="numberGenerate" min="0" max="9" style="
min-width: 150px;
max-width: 200px">
<button type='submit' onclick="myFunction(numberGenerate.value)">Generate</button>
<h4>Random generated values:</h4>
<p id="output"></p>
function myFunction(value) {
//Validation of input
if (value > 9 || value < 0) {
document.getElementById("output").innerHTML = "Number is not valid";
return false;
if (value == 0) {
document.getElementById("output").innerHTML = "Zero values generated:)";
return false;
//creation of variables
var url = '' + value
var text = "";
//function for fetching from API
async function getRandom() {
let response = await fetch(url);
let data = await response.json()
return data;
//function called to output random numbers
getRandom().then(data => {
for (var i = 0; i < data.length; i++) {
text += data[i] + "<br>";
document.getElementById("output").innerHTML = text;
}).catch(err => console.error(err))
\ No newline at end of file
This is a test if I can push!
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment