4 Replies - 437 Views - Last Post: 18 September 2013 - 03:34 PM

#1 skyline2162  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 112
  • Joined: 17-December 11

Not sure where my logic is going wrong

Posted 18 September 2013 - 12:47 PM

I am trying to read the contents of the array, if the array is empty i want it to continue and not print out the console, if its not empty then print out the contents of that array element

for (var library in output)
			{
				if (opt.options.showEmpty != true)
				{
					var j = 0;
					var check = arrayIsEmpty(output);
					if ( check == false && output[library] == "" )
						{
							continue;
						}
					else
						{
							console.log(library+ ",[" + output[library]+"]");
						}
				}
				//console.log(library+ ",[" + output[library]+"]");
			}


function arrayIsEmpty(attributes)
{
	for(var i = 0; i < attributes.length; i++)
	{
		if (attributes[i] == "")
			{
				return false;
			}
		else
			{
				return true;
			}
	}






Right now it prints out the empty ones too,

Is This A Good Question/Topic? 0
  • +

Replies To: Not sure where my logic is going wrong

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8371
  • View blog
  • Posts: 31,100
  • Joined: 12-June 08

Re: Not sure where my logic is going wrong

Posted 18 September 2013 - 12:55 PM

What language is this in?
Was This Post Helpful? 0
  • +
  • -

#3 skyline2162  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 112
  • Joined: 17-December 11

Re: Not sure where my logic is going wrong

Posted 18 September 2013 - 01:00 PM

javascript
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8371
  • View blog
  • Posts: 31,100
  • Joined: 12-June 08

Re: Not sure where my logic is going wrong

Posted 18 September 2013 - 01:10 PM

Theeeeeeeeeeeeeeen moving to javascript.
Was This Post Helpful? 1
  • +
  • -

#5 laytonsdad  Icon User is online

  • Cheese and Sprinkles
  • member icon

Reputation: 403
  • View blog
  • Posts: 1,720
  • Joined: 30-April 10

Re: Not sure where my logic is going wrong

Posted 18 September 2013 - 03:34 PM

Why not just test if the attributes length is 0, if it is zero there is nothing in it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1