Beta

Object to Array

Description:

Your task is to create two functions :

  • One function to turn an object into an array
  • One function to turn an array into an object

Examples :

arrayToObject([1, 1, 2, 2, 3, 3]) => {1:2, 2:2, 3:2}

objectToArray({2:5, 99:1}) => [2, 2, 2, 2, 2, 99]

arrayToObject receives an array. It must return an object, where the key is the values found in the array and the value is the number of times it was found({value:times_found})

objectToArray receives an object. It must return an array. Each value is repeated as many times as each key of the object. When the key of the object is a number, the values of the array must be numbers. (Ex : {1:5} must return [1,1,1,1,1] not ['1','1','1','1','1'] )

You must not change the value given in input.

Arrays
Algorithms

More By Author:

Check out these other kata created by AzariasB

Stats:

CreatedDec 30, 2016
PublishedDec 30, 2016
Warriors Trained371
Total Skips10
Total Code Submissions825
Total Times Completed186
JavaScript Completions186
Total Stars7
% of votes with a positive feedback rating79% of 86
Total "Very Satisfied" Votes61
Total "Somewhat Satisfied" Votes14
Total "Not Satisfied" Votes11
Total Rank Assessments79
Average Assessed Rank
7 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • AzariasB Avatar
  • HerrWert Avatar
Ad