dpjollygreen
Coder
So my site is a type of gaming environment for showcasing my kids art and practicing my own skills. It has a virtual shop and inventory that I populate using a series of the below, one for each item. It is an exact duplicate (aside from nomenclature) as one that is known to work, the rope. Short of it is I've used this exact technique for items that are working, but this one I traced back to this point using well placed innerHTML lines... I think.
My troubleshooting toolkit is limited so any assistance or advise you might have is greatly appreciated.
JavaScript:
////////////////////////////////////////////////////////////////////////////
if(inventory.includes("Helmet")){
const helmetString = /Helmet/g;
const helmetP2String = /Helmet_/g;
const matchHelmet = inventoryString.match(helmetString);
const matchHelmetP2 = inventoryString.match(helmetP2String);
//Problem area
document.getElementById("test").innerHTML = inventory;
let num1 = matchHelmet.length;
let num2 = matchHelmetP2.length;
document.getElementById("test2").innerHTML = inventory;
//Problem area
let numHelmet = num1 - num2;
for(let i = 0; i < numHelmet; i++){
let helmet = document.createElement('li');
let helmetLink = document.createElement('a');
helmetLink.textContent = "Helmet";
helmetLink.href = "javascript:sellHelmet()";
helmet.appendChild(helmetLink);
listInv.appendChild(helmet);
}
}
///////////////////////////////////////////////////////////////////////
Last edited by a moderator: