Skip to content

musatirgithub/IosCalculator

Repository files navigation

Hi there ✋. In this project, I've imitated IOS Calculator by using DOM. For this purpose;

  • First I've created a grid layout to place buttons, screen etc. and for styling I've used SASS,
  • I've grouped the buttons according to their functionality, within this context I've created arrays named "digits", "operands" and "others" and at each click code reacted in accordance with button group,
  • Capturing method was used for detecting which key was clicked,
  • I've defined variables by using DOM querySelector etc. ,
  • Navigated through DOM elements by using commands like getElementById, querySelector, querySelectorAll, parentElement etc.,
  • If calculation starts with "." code converts that to "0.",
  • It's possible to make consecutive calculations. When you click "+", "-", "x", "÷" buttons, if there was a previous operation code calculates the result then starts a new calculation,
  • If users presses "+", "-", "x", "÷" operands or "." more than once, code ignores latter click,
  • "±" and "%" buttons were taken into consideration and they work properly,
  • Decimal part of the result is limited by using toFixed method. Total length of the result is limited to 9,
  • When user clicks "=" style of the result changes and becomes a little bigger. In order to change style, I've added and removed a class to respective Div,
  • Gif image of the project is below 👇. Hope you like my project!