How do I map an string array string[] to a 2 dimensional array with strings [string, string]?
I tried
const animals: string[] = ['Dog', 'Cat', 'Mouse'];
// This throws an error
let splittedArray: [string, string] = animals.slice(0,2);
// This doesn't throw an error
// let splittedArray: [string, string] = ['Dog', 'Cat'];
// Error Message
// Type 'string[]' is missing the following properties from type '[string, string]': 0, 1 ts(2739)
My desired output should be:
console.log(splittedArray);
// ['Dog', 'Cat']
animals.slice(0, 2)...0, 1would give you just['Dog']Type 'string[]' is missing the following properties from type '[string, string]': 0, 1