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 6783283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:50:43+00:00 2026-05-26T16:50:43+00:00

Below is my code: This code is used to find the surrounding nodes when

  • 0

Below is my code:
This code is used to find the surrounding nodes when supplied with a given node.

i.e

enter image description here

for(var i:uint = 0;i < nodes.length; i++){
            test_node = this.nodes[i];
            if (test_node.row < node.row - 1 || test_node.row > node.row + 1) continue;
            if (test_node.column < node.column - 1 || test_node.column > node.column + 1) continue;
            surrounding_nodes.push(test_node)

        }
/*
nodes contains an array of objects.
node is an object I want to use as my test variable. 
property row contains the row in which the object is located
proerty column contains the cloumn in which the object is located
*/  

I’m getting correct results (as I am following a tutorial), although I am not sure why?

this is what I’m thinking.

  1. if the test_node row is below node row location, or if the test_node
    row is above the node row – continue

  2. if the test_node column is to the left of the node column location continue or if the test_node column is to the right of the
    node column – continue.

Assume the above image case.
Therefore, shouldn’t surrounding_nodes contain all the objects in nodes (bar the actual node), as every object is going to satisfy the above statement, because and object is either going to be above or below node or to the left or right of it.

what this code actually does is only find the nodes surrounding the node (red square).

could someone actually help me understand these if statement.

thanks

  • 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-26T16:50:43+00:00Added an answer on May 26, 2026 at 4:50 pm

    Just substitute the conditionals with numbers and you see how it works.

    In the image above node is on row 4 and column 4 (0-based) and let’s take a test_node on row 2
    then

    if (test_node.row < node.row - 1 || test_node.row > node.row + 1)
    

    translates to

    if (2 < 3 || 2 > 5 ) continue
    

    continue means “skip the rest of this iteration and start the next one”

    so now take test_node on row 3 and column 3

    if ( 3 < 3 || 3 > 5 ) continue
    if ( 3 < 3 || 3 > 5 ) continue
    

    all 4 conditions are false so it adds it to surrounding_nodes

    — EDIT —

    BTW if you label your loop it’s more legible what happens

    iterateNodes : for(var i:uint = 0;i < nodes.length; i++){
        test_node = this.nodes[i];
        if (test_node.row < node.row - 1 || test_node.row > node.row + 1) continue iterateNodes;
        if (test_node.column < node.column - 1 || test_node.column > node.column + 1) continue iterateNodes;
        surrounding_nodes.push(test_node);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code below on my website. It's used to find the
Basically this code below returns the right information, but I need to add the
This code below is for executing ls -l | wc -l. In the code,
This code below works in all web browsers except IE: <input type="text" name="passwordLogin" value="Password"
I have this code below. As you can see I am passing two variables
i am using this code below to dynamically capture the name of the button
How can this code compile? The code below in the operator int CAN access
Hi I'm using this code below to let a user draw their signature on
i want to put the id into the colorbox below this code nom works
I have this javascript code below that uses jquery, it is suppoed to be

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.