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

  • Home
  • SEARCH
  • 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 6622229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:22:45+00:00 2026-05-25T21:22:45+00:00

the question is pretty similar to this thread Javascript..totally lost in this tutorial .

  • 0

the question is pretty similar to this thread Javascript..totally lost in this tutorial.

    function findSequence(goal) {
      function find(start, history) {
        if (start == goal)
          return history;
        else if (start > goal)
          return null;
        else
          return find(start + 5, "(" + history + " + 5)") ||
                 find(start * 3, "(" + history + " * 3)");
      }
      return find(1, "1");
    }

    print(findSequence(24));

I got stuck at this part :

    find(start * 3, "(" + history + " * 3)"); 

each time start goes beyond goal what does it do? it says it return null but when I test and put breakpoint on

    if (start == goal) it shoes this on the console

    history: "(((((1 + 5) + 5) + 5) + 5) + 5)"
    start: 26

    history: "(((((1 + 5) + 5) + 5) + 5) * 3)"
    start: 63

it add up *3 and take off +5, I don’t understand how.

  • 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-05-25T21:22:46+00:00Added an answer on May 25, 2026 at 9:22 pm

    The return statement:

          return find(start + 5, "(" + history + " + 5)") ||
                 find(start * 3, "(" + history + " * 3)");
    

    is an expression involving the “||” operator. That operator will cause the left-hand side to be evaluated. If the result of that is not null, zero, false, or the empty string, then that value will be returned. If it is one of those “falsy” values, then the second expression is evaluated and returned.

    In other words, that could be re-written like this:

           var plusFive = find(start + 5, "(" + history + " + 5)");
           if (plusFive !== null)
             return plusFive;
           return find(start * 3, "(" + history + " * 3)")
    

    If “start” ever exceeds “goal”, the function returns null. Of course, if both the alternatives don’t work, then the whole thing will return null.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is pretty much similar to this one , but for SQL Server
I asked a pretty similar question a few days ago, but this one is
My question is pretty similar to this one . I am working in company
Just asked a question pretty similar to this one... Currently I am doing a
Somewhat related to this question . Outline and border are pretty similar (although they
Question is pretty self explanitory. I want to do a simple find and replace,
This question is pretty much the same as this .Net question exept for java.
I think the question is pretty self explanatory. Anyone done this before? UPDATE :
I'm asking a question very similar to this one —dare I say identical? An
This is similar to a recent question. I will be maintaining sorted a list

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.