Https://Www.Typescriptlang.Org/Play/?Ssl=1&Ssc=61&Pln=1&Pc=72#Code/C4TwDgpgBAcg9gOxgVwDaoIYCNUQPJYBWEAxsADwAqAfFALxQDeUA2gApQCWCUA1hCDgAzKJQC6AWgD8ALliIU6bLnIARCBDDwkaTDghV2Y6rQC+AKFCR5OpfoCCAJ0cYQVWg0pQIAD2AQEABMAZygnFzduIQhHKAA1Wikw51dybUU9XAJiMnIE6hlKS3BodU103WUDGnpRbz8AkKg4IlJgKCSKuyzW3Jq5LsyIcNSaYuscDFrGcyg5qAxZKGDgR24AcwBuWfmsOQRkAFssGIAfZCCIIW4IQO35qBI5GYeHxbkVtYQtndeoPagB2OMXu81MABpflB1nIRm4Xn8FktPhtQX8AUCTo40VBTNRzBZzESiVZoOtaoMqtk2uRJviSIgVstgnJyQwLoErjdAgtQhgECBzMFggA6EgijAi3DfYAACyFovWLAADGIJVKAus5UA
Вот так можно с массивом