File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments