Why does this not work? [Answered]
Hey, pretty new to coding and trying some things out, someone knows why it says that my var "randomNumber" is not in the context?
7 Replies
randomNumber = NumberGen;
tries to assign a new value to an existing variable. However the variable randomNumber
was never declared, so it doesn't exist at that point. I think you probably meant int randomNumber = NumberGen();
(You also need to call the NumberGen
method, by putting ()
after the method name)ahh i see okay i changed it, but now it says that it doesnt get a return value
you don't return the
number
that's generated in NumberGen()
Ohhh i understand so basically NumberGen has no var until i use
return number;
right?
right, it has no value until you actually
return
something
in your case, yes number
Aight, thanks a lot!
✅ This post has been marked as answered!