+ 2
Easter Egg help
So I want to hide the last link in the dropdown until the div is clicked 5 times. What am I doing wrong? You can completely rewrite it if needed. https://code.sololearn.com/WZ4ML8Fptjx5/?ref=app
17 odpowiedzi
+ 2
You need to call Test() in Add()
+ 1
Daniel Cooper autocorrect is so annoying
+ 1
import math
import String
int totaleggs =0
int amt = 0
int totalfound = 0
String str= Keep Hunting,Candy Time
for(int i=0;i<=100;i++)
{
if(totaleggs == 40 && totaleggs !=60)
print("Keep Hunting")
elif(totaleggs == 60 && totaleggs !=100)
print("Candy Time")
elif(totaleggs !=60 && totaleggs == 100)
print("Candy Time")
}
""""for(int i=0;i<=100;i++)
{
if(totaleggs == 40 && totalfound !=60)
print("Keep Hunting")
elif(totaleggs == 60 && totalfound !=100)
print("Candy Time")
elif(totaleggs !=60 && totalfound == 100)
print("Candy Time")
}
""""
+ 1
import math
import String
int totaleggs =0
int amt = 0
int totalfound = 0
String str= Keep Hunting,Candy Time
for(int i=0;i<=100;i++)
{
if(totaleggs == 40 && totaleggs !=60)
print("Keep Hunting")
elif(totaleggs == 60 && totaleggs !=100)
print("Candy Time")
elif(totaleggs !=60 && totaleggs == 100)
print("Candy Time")
}
""""for(int i=0;i<=100;i++)
{
if(totaleggs == 40 && totalfound !=60)
print("Keep Hunting")
elif(totaleggs == 60 && totalfound !=100)
print("Candy Time")
elif(totaleggs !=60 && totalfound == 100)
print("Candy Time")
}
""""
0
what is the point of writing “var bool = false” and then “bool != bool”? just writing “var bool = true” gives the same effect. Or better yet, why not just omit the whole bool thing and just write “if(true)”? the bool seems kinda useless. What is its purpose meant to be? you get the same result just writing “if(true)” and as far as I could see, bool appears nowhere else in the code, so omitting it wouldnt have an effect on anything else. I’m a little confused as to its purpose.
0
The entire code is a mess, as I'm new to coding.
0
Rora
I actually just learned about booleans, plus I'm new to coding. So if you ever see anything that seems wrong or anything that could in any way be improved, please let me know.
But I added that because that's the only way I knew to do it. so do I not need the variable?
0
Daniel Cooper https://code.sololearn.com/WQVVgTdq7SXs/?ref=app
here’s why its unecessary:
first, you set bool equal to ‘false’
next, you said that bool != bool. When you write it like that, you are telling the computer a fact, that bool doesnt equal bool. Therefore, it will always evaluate to true, because you arent asking the computer anything, you’re telling it, and whatever you tell the computer it will take as fact, and facts are always true.
then, you wrote if(bool). this is the same as writing if(bool == true), and since you just told the computer that bool is true and there is nothing else in the code that changes the value of bool, bool will always be true so you can just omit the variable because variables change (theyre called “variables” after all) and this is static, so writing “if(bool)” is the same as “if(true)” because bool will ALWAYS equal true.
I hope this makes sense to you. If not, I can try to clarify further.
0
Thanks! I thought you had to declare a boolean variable because that's the only way I saw online.
I think they need more about booleans in the js course.
0
also Rora
"!" is a boolean operator.
It returns true if the bool is false
and false if the bool is true
so bool =! bool is basically saying that it needs to change bool to true or false depending on what it already is.
So if bool is true, it changes it to false
"!=" is the operator you're thinking of. It's a comparison operator that checks if two things aren't equal.
0
Daniel Cooper you are right, sorry, I read that wrong. I was not looking at the code as I wrote that, so I was doing it from memory.
0
Rora It's ok xD
I accidentally typed it as != the first time.
0
Daniel Cooper if you type like bool = !bool, then it becomes easier to read and remember
0
Rora I did, but my phone keyboard automatically removes spaces before certain characters. Makes coding annoying on mobile. xD
0
I normally do something like "bool = !bool"
0
Here is my coding solution for Easter eggs in c++
https://code.sololearn.com/c646K0Ld2k3u/?ref=app