Skip to content

Commit f55cf37

Browse files
committed
minor fixes
1 parent aa298da commit f55cf37

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/recursion.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const checkMatchingLeaves = (obj) => {
4141
//we take a empty array where we will store all the values form the inner objects.
4242
// we invoke an Immidiately Invoked Functional Expression(IIFE), with the object passed as parameter.
4343
// we get all the keys of the params and loop through and check if any key is an object or not
44-
// if we find any inner object, we call the rec, recursively with the found key(inner object).
44+
// if we find any inner object, we call the rec, recursively with that key's corresponding value(inner object).
4545
// if its not an object we populate the empty array with its corresponding value.
4646
//after the foreach is finished, we exit the IIFE.
4747
// check if the values array contains all same item or not , if yes return true, else return false.
@@ -51,8 +51,8 @@ const checkMatchingLeaves = (obj) => {
5151
(
5252
function rec(param) {
5353
Object.keys(param).forEach(function(key) {
54-
if (typeof param[key] === 'object') return rec(param[key]);
55-
values.push(param[key])
54+
if (typeof param[key] === 'object') return rec(param[key]);// keep repeating until it is not an object.
55+
values.push(param[key])// push the value.
5656
})
5757
}
5858
)(obj);

0 commit comments

Comments
 (0)