Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* I am getting "TypeError: historyObject is undefined" at the line
- "currentNum = historyObject.lastNum;"
- Any help would be appreciated */
- let currentNum = 0;
- let storedNum = 0;
- let history = [];
- let historyIndex = null;
- function addHistory() {
- let historyObject = {lastNum: currentNum,
- value: storedNum};
- history.unshift(historyObject);
- historyIndex = null;
- function historyBack() {
- if (historyIndex === history.length - 1) {
- return;
- }
- if (historyIndex === null) {
- historyIndex = 0;
- } else {
- historyIndex++;
- }
- setHistoryValues();
- }
- function setHistoryValues() {
- let historyObject = history[historyIndex];
- currentNum = historyObject.lastNum;
- storedNum = historyObject.value;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement