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

Use of conditionals IF

Guest
Dec 10, 2019 Dec 10, 2019

Good morning, I'm doing an exercise and I want to use the conditional if, I did this code but it doesn't work for me, someone knows why it is.

 

Basically it is that when you click on an object it disappears and when all disappears that I display a message of retro feeding.

 

 


var _this = this;

_this.retro.visible = false;

_this.hit_fruta.on('click', function(){

 

_this.mc_fruta.visible = false;

_this.hit_fruta.visible = false;

SigEjer();

});

 

_this.hit_gato.on('click', function(){

 

_this.mc_pan.visible = false;

_this.hit_gato.visible = false;

SigEjer();

});

 

_this.hit_laptop.on('click', function(){

 

_this.mc_basura1.visible = false;

_this.hit_laptop.visible = false;

SigEjer();

});

 

_this.hit_consola.on('click', function(){

 

_this.mc_basura3.visible = false;

_this.hit_consola.visible = false;

SigEjer();

});

 

_this.hit_pelota.on('click', function(){

 

_this.mc_basura2.visible = false;

_this.hit_pelota.visible = false;

SigEjer();

});

 

_this.hit_paraguas.on('click', function(){

 

_this.mc_mesa.visible = false;

_this.hit_paraguas.visible = false;

SigEjer();

});

 

function SigEjer() {

if ( mc_mesa1._visible = false &&

mc_basura1._visible = false &&

mc_basura2._visible = false &&

mc_pan._visible = false &&

mc_fruta._visible = false &&

mc_basura3._visible = false

){

_this.retro.visible = true;

}

}

TOPICS
Code , Error
321
Translate
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 1 Correct answer

Community Expert , Dec 10, 2019 Dec 10, 2019

Hi.

 

Your code has at least three problems.

 

Inside of your SigEjer function body:

- You are referencing all objects in the if statement without _this (I suppose this is the correct context);

- There is no underscore in the visible property. It must be visible not _visible;

- You are using an assignment operator (=) in the if statement. You must use double equals (loose equality) or tripe equals (strict equality).

 

I hope this helps.

 

 

Regards,

JC

Translate
Community Expert ,
Dec 10, 2019 Dec 10, 2019

Hi.

 

Your code has at least three problems.

 

Inside of your SigEjer function body:

- You are referencing all objects in the if statement without _this (I suppose this is the correct context);

- There is no underscore in the visible property. It must be visible not _visible;

- You are using an assignment operator (=) in the if statement. You must use double equals (loose equality) or tripe equals (strict equality).

 

I hope this helps.

 

 

Regards,

JC

Translate
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
Guest
Dec 10, 2019 Dec 10, 2019
LATEST

Thank you very much, the advice worked for me.

Translate
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