6 kyu
Tree Depth
462 of 526leesharma
Description:
Write a method that takes a nested hash (object in javascript) as input and returns that hash with added "depth" keys. So, for example, the following input:
{ a: 1, b: 2, c: { d: { e: 3 } } }
would yield the following return value:
{ a: 1, b: 2, c: { d: { e: 3, depth: 2 }, depth: 1 }, depth: 0 }
For Ruby, if the input is not a hash, then the function should return nil.
For JavaScript, if the input is not an object (including an array), the function should return null
.
Trees
Recursion
Fundamentals
Similar Kata:
Stats:
Created | Aug 15, 2015 |
Published | Aug 15, 2015 |
Warriors Trained | 1063 |
Total Skips | 47 |
Total Code Submissions | 4047 |
Total Times Completed | 526 |
Ruby Completions | 71 |
JavaScript Completions | 462 |
Total Stars | 16 |
% of votes with a positive feedback rating | 85% of 110 |
Total "Very Satisfied" Votes | 85 |
Total "Somewhat Satisfied" Votes | 17 |
Total "Not Satisfied" Votes | 8 |
Total Rank Assessments | 14 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |