Final Calculator Design

<!DOCTYPE html>
<html>
<head>
<title>JavaScript</title>
<script type="text/javascript">var n1=prompt("Please key in a random number.","e.g.123");
var n2=prompt("Please key in a random number.","e.g.123");
var result=n1*n2;
alert(result);</script>
</head>
</html>
Design a Calculator
prompt()
is a dialogue box that user can key in values, and it will close until the user submit or cancel.
Basing on the rule, we separate the user behavior into steps, like:
input: prompt(default value or an example)
→ operate → output: alert(data)
For example, to create a simple calculator…
var n1=prompt("Please key in a random number." , "7");

var n2=prompt("Please key in a random number." , "7");

var result=n1*n2;
alert(result);
=> The result is 49.

Music of Today: 馬祖小夜曲 Ma-Chu Song by MC Hotdog 熱狗 Feat. Agota
Clap/Share/Follow
If you guys find this article helpful, please kindly do the writer a favor — giving 5 clicks at the GREEN area and 10~50 claps at the bottom of this page.
Most important of all, feel free to comment and share your ideas below to learn together!