Create Tree From Array Javascript Methods Syntax