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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:48:17+00:00 2026-05-23T21:48:17+00:00

I have a for loop that I am using to draw stuff from an

  • 0

I have a for loop that I am using to draw stuff from an array on to a canvas. The array holds a bunch of variables.

These variables contain qualitative values like firstName, lastName, team, etc.

I know the variables are set up correctly because my other functions using them work fine. However, I have a for loop that is suppose to be drawing circles on the canvas only if team = ‘blue’ .

The problem is that it is recognizing them all as being ‘blue’ and drawing them all, when in fact only a few are ‘blue’ and other are ‘red’, ‘green’, etc.

here is the code:

            ctx.fillGroups = function(g){
                for ( var i=0; i<allSeating.length; ++i ){
                    if (allSeating[i.team]=g){
                        ctx.beginPath();
                        ctx.fillPerson(allSeating[i]);
                        //alert(allSeating[i.team]);
                    }
                }
            }

With the alert() active i can see that it thinks they are all blue.

I am guessing the issue lies with the line: if (allSeating[i.team]=g) but I cant seem to get it to work. Does the check for allSeating[i.team]=g need to happen elsewhere? But then why does it think that they are all blue team anyway?

UPDATE: still not working here is a demo http://jsfiddle.net/8ryvH/1/

  • 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-23T21:48:17+00:00Added an answer on May 23, 2026 at 9:48 pm

    allSeating[i.team]=g is not a check: it is an assignment statement.

    What about allSeating[i.team]==g instead? (Am I missing something?)

    The Mozilla Developer’s Network JavaScript Documentation is a great resource for this sort of thing.

    Update:

    As said elsewhere, there’s more here than = or ===.

    We noted in chat that allSeating[i].team === g is probably what you want to evaluate, but things still didn’t add up.

    I think the seat object is the problem, or rather the instantiation of it.

    The definition has eight properties, but your instantiations have only seven.

    Adding a value for the fillStyle property, as shown below, corrected the problem for me, and allSeating[i].team === g now evaluates true.

    var markTwain = new Seat(758, 180, 9,fillStyle,"Mark", "Twain", 6207, "red");

    Please let me know if you’ve got any more trouble.

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

Sidebar

Related Questions

I have a loop that reads each line in a file using getline() :
I have a UIImage that I'm instantiating using imageWithData: (the data is loaded from
I have a loop that has to go from N to 0 (inclusively). My
I have this simple problem that gets an input from the user using a
In my WPF client, I have a loop that calls a WCF service to
I'm trying to solve the 3n+1 problem and I have a for loop that
I have two SQL scripts which get called within a loop that accept a
I have a loop on page to update an access database that takes 15-20
So I have an IList of business entities that I loop through in a
I have a variable that is built in loop. Something like: $str = ;

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.