Skip to content

Latest commit

 

History

History
27 lines (22 loc) · 1.61 KB

File metadata and controls

27 lines (22 loc) · 1.61 KB

Count Element Number To Object medium

by 凤之兮原 @kongmingLatern

Take the Challenge    简体中文

With type CountElementNumberToObject, get the number of occurrences of every item from an array and return them in an object. For example:

type Simple1 = CountElementNumberToObject<[]> // return {}
type Simple2 = CountElementNumberToObject<[1,2,3,4,5]> 
// return {
//   1: 1,
//   2: 1,
//   3: 1,
//   4: 1,
//   5: 1
// }

type Simple3 = CountElementNumberToObject<[1,2,3,4,5,[1,2,3]]> 
// return {
//   1: 2,
//   2: 2,
//   3: 2,
//   4: 1,
//   5: 1
// }

Back Share your Solutions Check out Solutions