I’m new to es6, using const and the overall implications that has on the scope of a function. Whenever this function is output, it always says it failed to add all items. Is there something glaringly obvious preventing the loaded const from equaling the total const?
const addContent = function() {
const getTotal = function() {
const total = Number("`3");
return total;
};
let content = "<div><span>";
const loaded = 3;
const total = getTotal();
for (let i = 0; i < loaded; i++) {
content += "<h2>Test " + i + "</h2>";
}
const results = loaded == total ? "<h3>Added all of the items.</h3>" : "<h3>Failed to add all of the items.</h3>";
content += results + "</span></div>";
return content;
};