Thanks to @Aplet123 I can store literal strings in an array as functions. (previous issue) This works great. But I can’t figure out how to do the same with nested arrays. For example:
var nameTemp = `Placeholder`;
Title[0] = () => `what are you called?`;
Title[1] = () => `what does ${nameTemp} do?`;
Title[2] = () => `How old is ${nameTemp} ?`;
//--I get the users name from an input.text element and store in nameTemp
textbox.textContent = Title[1]();
This works well. It returns “what does [name entered] do?” and updates the Literal string when Title[x]()
is called.
But I have multiple text items per page and I’d like to be able to retrieve them using something like:
Title[1][1] = () => `what does ${nameTemp} do?`;
I’ve tried various things, but they either don’t return the length of the second array, or don’t run the function:
var testC = [];
testC[0] = [];
testC[0][0] = () => ` what does ${nameTemp} do?`;
console.log(testC[0][0]);
this just returns “() => ` what does ${nameTemp} do?” it doesn’t run the function.
Any ideas? Thanks in advance for any help.