Struggling to return a type-safe Typescript v3.5 array without having to declare it within the method body? This array should consist of multiple string arrays.
Desiring something along the lines of:
foo(): Array<Array<string>>:
// perform some action
return new Array<Array: string>>
Extra challenge: How can you return an array that contains arrays without explicitly declaring all those arrays in the code body?
LATEST UPDATE:
foo(): Array<Array<string>> {
// determine 'someSize' and 'anotherSize'
// initialize both arrays:
let tempPartOfSpeechArr: string[] = new Array(someSize);
let tempLinguisticUsageArr: string[] = new Array(anotherSize);
let arrContainer = new Array(2);
arrContainer[0] = tempPartOfSpeechArr;
arrContainer[1] = tempLinguisticUsageArr;
return arrContainer;
I just aim to return the arrContainer with both arrays inside. Trying to keep the code concise while maintaining readability.