This question evaluates a candidate's ability to model and manage UI state, handle event-driven input, and implement correct operator chaining in a calculator component, testing frontend state management and user interface behavior within the software engineering fundamentals domain.
Implement a calculator UI component.
Requirements:
+
,
-
,
*
, and
/
.
=
to finalize the current calculation.
Example behavior:
1
,
+
,
100
,
+
,
20
,
=
+
is pressed, the display should immediately show
101
.
=
is pressed, the display should show
121
.
Explain how you would model the calculator state and implement operator chaining so the UI always shows the correct current value.