Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

练习题 - 计算器 - 1 #2

Open
zhbhun opened this issue Jun 20, 2022 · 0 comments
Open

练习题 - 计算器 - 1 #2

zhbhun opened this issue Jun 20, 2022 · 0 comments
Labels

Comments

@zhbhun
Copy link
Owner

zhbhun commented Jun 20, 2022

每周给自己找一个题目进行编码练习。

计算器

计算器不仅是最有用的工具之一,而且也是了解应用程序中 UI 和事件处理的好方法。在这个问题中,你将创建一个支持整数的基本算术计算的计算器。

限制

  • 你不可以使用 eval() 函数来执行计算
  • 你不可以使用 new Function('...') 函数来执行计算

用例

  • 用户可以看到显示屏显示当前输入的数字或最后一次操作的结果。
  • 用户可以看到一个包含数字 0-9、操作符 —— '+'、'-'、'*'、'/' 和 '=' 按钮的输入板,一个 'AC' 按钮(用于清除所有)。
  • 用户可以通过点击输入板上的数字来输入最多八位数的数字序列,任何超过8位的数字的输入都将被忽略。
  • 用户可以点击 'AC' 按钮来清除所有的内部工作区域,并将显示值设为 0。

脚手架

https://codesandbox.io/s/calculator-c8tnv1

ps:计算器样式拷贝自 https://codepen.io/ssmkhrj/full/jOWBQqO

参考文献

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant