I have the following function, that takes a string from an input, and puts it inside a global array, but as I go to the next page, the global array gets empty, as if nothing happened.
checkItems = [];
function addToCart() {
"use strict";
var p = document.getElementById('buy-item-input').value;
var verifyItem = 0;
/* some other code... */
checkItems.push(p);
location.href = 'pay.html';
}
I've put console.log before chaning the window just to verify that the array gets the data before going to the next page, and it does, but when I try it again at the next page, it's gone...