-3
People, I’m doing an exercise to create a set of stone, paper and scissors. Within the development I arrived at a problem, my if statement is not working. To with 1 month of programming only, then ta half complex hahah
$(".circle").click((e) => {
const paper = $("#paper");
const scissors = $("#scissors");
const rock = $("#rock");
const event = e.currentTarget;
if (event === paper) {
scissors.addClass("hide");
rock.addClass("hide");
$("#triangle").addClass("hide");
} else if ...*CÓDIGO CONTINUA A MESMA LÓGICA*
I also have the console.log from const paper and const Event
console paper
S.fn.init [div#paper.circle.paper]
0: div#paper.circle.paper
length: 1
proto: Object(0)
console event
<div id="paper" role="button" class="circle paper">
<img src="images/icon-paper.svg" alt="" />
</div>
In my little understanding of programming I find myself not knowing what to do!!
Somebody help me out there?
Bro, I’m still looking at the example you made of the game, but I think you saved my life here. It was worth too
– Gabriel
@Gabriel, has
n
ways to make this little game, just like any other code. It’s the same thing as writing sentences. You can create a phrase with the same meaning as mine using other words. See what you like in my code and start using too, but the important thing is you try to create your version, train what you have learned. Hugs!– Pedro
I tried it here and it kept not working using this. I had tried it before and when I do a console.log it doesn’t return an id. When I do the way you showed, my return is Undefined. My "boot" is a div I’ve put role="button" pq to using image and other things like button. Maybe that’s it? Even so, I don’t know why I can’t do it with this and the currentTarget, since the return of it is the same as my paper/terousa/stone
– Gabriel