Please select one of the following:

     




The contents of the body in the HTML file:

<script src="script.js"></script>

<p><strong>Please select one of the following:</strong></p>
    
<button onclick="getName()" style="padding:15px">Name</button>&nbsp;&nbsp;
<button onclick="age()" style="padding:15px">Age</button>&nbsp;&nbsp;
<button onclick="roll()" style="padding:15px">Roll a Die</button>

<p>
<div id="output"></div>
</p>


The contents of the Javascript file:

function output(stringToOutput) {
  document.getElementById("output").innerHTML = stringToOutput;
}

function roll() {
  output(Math.floor(Math.random() * 6));
}

function getName() {
  let input = prompt("What is your name?");
  if (input !== null && input.trim().length > 0)
    output(`Nice to meet you, ${input}`);
  else
    output(`You don't want to tell me your name?`);
}

function age() {
  let input = Number(prompt("How old are you?"));
  if (input !== null && !isNaN(input) && input > 0)
    output(`You are ${input} year(s) old already?`);
  else
    output(`Don't be ashamed of your age, tell me!`);
}