+ 1
How can I save the history of operations made in an HTML calculator?
I need to store the operations done and show them in the Calculator. Does anyone know?
3 odpowiedzi
+ 2
well, I added function calling from the equal button (called makeHistory(result) )
line 32-34 with semicolon and plus (; , +)
that takes the results and saves them in the array of object that called History
And created button that logs that in the console
you can change it to another interface like innerHTML or alert box
you don't must to use the console it's only for the example (as you can see that isn't good idea to use its)
hope I helped.
https://code.sololearn.com/Wo9Sz4UXNXM3/?ref=app
+ 1
u have to create a array of objects (called history) and update your array with every operation using history.push(last operation => result, calculate, whatever )
And create button that calls to function that shows your array
https://code.sololearn.com/WEujGp5o8l36/?ref=app
+ 1
Look my code:
https://code.sololearn.com/W98pnsCDhl2l/#html