<form>
element is a container that contains different type of input elements.
in this project: I used <input>
and <button>
as a input elements inside the <form>
The elements that doesn't need closing tag is called Empty or Void elements.
<input type="button" value="1">
type="button"
will create a button element on the webpage value=" 1 "
defines that the number that is going to be the value of the button.
<input type="button" value="DE" onclick="display.value = display.value.toString().slice(0,-1)">
This particular part the code about the button DE(which deletes the lastly displayed number)
during the onclick display.value
will go through the following process to it's action done.
display.value.toString
= will take the value from the display and convert the value into string.
toString.slice()
= will returns the selected elements as a new array.
slice(start,end)
= start is the staring position we want for the new array/default is 0.
end is the end position/default is last element .
slice(0,-1)
\= so the starting will be not changing but the end position eliminates last element from the array and returns it. if the end is -2 then it eliminates the last two elements.
eval()
is an function property. it evaluate the strings and return the value. used this function for done the calculation part.
Live link:https://vaithegiv.github.io/Calculator
Source code: Check the link for the source code: https://github.com/VaithegiV/Calculator.git