• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Probleme mit Klammern

Explorer ,
May 21, 2020 May 21, 2020

Copy link to clipboard

Copied

hallo, was fuer klammern muss ich setzen ??

{gehe.menue_land_[i].visible = false;}

 

danke vorab

for (var i = 1; i <= 2; i++) {

		if (i == 1) {

			{gehe.menue_land_1.visible = true;}

		} else
		{gehe.menue_land_[i].visible = false;}

		}

 ( 

Views

637

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , May 21, 2020 May 21, 2020

Hi.

 

To use bracket notation, put the fixed part of the name between quotes then add the variable part using the + operator. Like this:

for (var i = 1; i <= 2; i++)
{
	if (i == 1)
	{
		gehe["menue_land_" + i].visible = true;
	}
	else
	{
		gehe["menue_land_" + i].visible = false;
	}
}

 

Also, you have unneeded extra curly braces here:

{gehe.menue_land_1.visible = true;}

 

And as a bonus, your whole code could be written like this:

for (var i = 1; i <= 2; i++)
	gehe["menue_land_" + i].visible = i
...

Votes

Translate

Translate
Explorer , May 21, 2020 May 21, 2020

Danke !!!!

Funktioniert !!!

Votes

Translate

Translate
Community Expert ,
May 21, 2020 May 21, 2020

Copy link to clipboard

Copied

Hi.

 

To use bracket notation, put the fixed part of the name between quotes then add the variable part using the + operator. Like this:

for (var i = 1; i <= 2; i++)
{
	if (i == 1)
	{
		gehe["menue_land_" + i].visible = true;
	}
	else
	{
		gehe["menue_land_" + i].visible = false;
	}
}

 

Also, you have unneeded extra curly braces here:

{gehe.menue_land_1.visible = true;}

 

And as a bonus, your whole code could be written like this:

for (var i = 1; i <= 2; i++)
	gehe["menue_land_" + i].visible = i == 1;

 

Please let us know if you have any further questions.

 

Regards,

JC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 21, 2020 May 21, 2020

Copy link to clipboard

Copied

Danke !!!!

Funktioniert !!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 21, 2020 May 21, 2020

Copy link to clipboard

Copied

LATEST

Excellent!

 

You're welcome!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines