Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9151729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:52:24+00:00 2026-06-17T11:52:24+00:00

I have many levels of nested comments inside my commentsArray (This is pulled in

  • 0

I have many levels of nested comments inside my commentsArray

(This is pulled in from an API and cannot be changed)

commentsArray = [
    {
        author: "jeff"
        replies: [
            {
                author: "jeff"
                replies: [
                    {
                        author: "simon"
                    }
                ]
            },
            {
                author: "simon"
            }
        ]
    },
    {
        author: "simon"
    }
]

I also have a recursive function, dialogueParse, that calls itself if the object in question has “replies“

dialogueParse = (comment) ->
    for child in comment
        if child.author is "simon"
            console.log "Simon was found.."

        if child.replies
            dialogueParse child

However, this code doesn’t seem to work correctly. After I call the function initially:

dialogueParse commentsArray

..for some reason, only the one located on the first level (at the end of the array) is found.

“simon” is listed as an author in 3 different places.

I’ve been working on this for several hours and getting nowhere. Any help is more than appreciated! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:52:25+00:00Added an answer on June 17, 2026 at 11:52 am

    Shouldn’t you be passing child.replies as the argument in the recursion?

    As in:

    dialogueParse = (comment) ->
        for child in comment
            if child.author is "simon"
                console.log "Simon was found.."
    
            if child.replies
                dialogueParse child.replies
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many levels of a nested hash like: { :foo => 'bar', :foo1
I have a hierarchy of tables 3 levels deep (QualificaionType has many QualificationGroups, which
We have many projects with several files inside each. Files can be checked in
I have a three-level multi-nested form in Rails. The setup is like this: Projects
I have a large class with many nested subclasses of different types as follows:
I have data nested in to levels: L1 L2 x1 x2 x3 x4 A
I have a Flight model nested inside a FlightLog model. A FlightLog may contain
We have to store lot of images with nested folder structure levels which is
I have multiple level parent-child tables(GrandParent, Parent and Child, all many to one relation,
I have many different NSArray 's stored in .dat files, in the Documents folder

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.