abs
<!-- save as Absolute Value.html -->
<html><head>
<title> Absolute Value </title>
<script>
function theAbsoluteValue()
{
let question = prompt("Enter a number", "");
let answer = Math.abs(question);
return answer;
}
function displayIt(where, whatFunction) //DISPLAY ANSWER
{
document.getElementById(where).innerHTML = whatFunction;
}
</script>
</head>
<body>
<button onclick="displayIt('div1', theAbsoluteValue());">
Absolute Value
</button>
<div id="div1"></div>
</body>
</html>
<html><head>
<title> Absolute Value </title>
<script>
function theAbsoluteValue()
{
let question = prompt("Enter a number", "");
let answer = Math.abs(question);
return answer;
}
function displayIt(where, whatFunction) //DISPLAY ANSWER
{
document.getElementById(where).innerHTML = whatFunction;
}
</script>
</head>
<body>
<button onclick="displayIt('div1', theAbsoluteValue());">
Absolute Value
</button>
<div id="div1"></div>
</body>
</html>