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

Use of conditionals IF

New Here ,
Dec 10, 2019 Dec 10, 2019

Copy link to clipboard

Copied

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

Views

182

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 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

Votes

Translate

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

Copy link to clipboard

Copied

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

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
New Here ,
Dec 10, 2019 Dec 10, 2019

Copy link to clipboard

Copied

LATEST

Thank you very much, the advice worked for me.

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