Sum by Type

Sum by Type

You have an array. Each value from that array can be either a string or an integer. Your task here is to return two values. The first one is a concatenation of all strings from the given array. The second one is a sum of all integers from the given array.

Input: An array of strings and integers.

Output: An array.

Examples:

assert.deepStrictEqual(sumByTypes([]), ["", 0]);
assert.deepStrictEqual(sumByTypes([1, 2, 3]), ["", 6]);
assert.deepStrictEqual(sumByTypes(["1", 2, 3]), ["1", 5]);
assert.deepStrictEqual(sumByTypes(["1", "2", 3]), ["12", 3]);

How it’s used: Input the values of different types and different operations with them, depending of type, is the usual thing in development.

19