Beta
Object to Array
186AzariasB
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
Similar Kata:
Stats:
Created | Dec 30, 2016 |
Published | Dec 30, 2016 |
Warriors Trained | 371 |
Total Skips | 10 |
Total Code Submissions | 825 |
Total Times Completed | 186 |
JavaScript Completions | 186 |
Total Stars | 7 |
% of votes with a positive feedback rating | 79% of 86 |
Total "Very Satisfied" Votes | 61 |
Total "Somewhat Satisfied" Votes | 14 |
Total "Not Satisfied" Votes | 11 |
Total Rank Assessments | 79 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 8 kyu |