First, welcome to web development. It's an industry that only continues to grow. We'd be happy to help with specific questions.
As far as just getting started with all the concepts, nothing beats a good book. The website linked is great, but usually book authors take much more time to explain things.
I wish I could recommend a good current book, but I started web development back in the 90s. That crap is out of print by now I'm sure. But, once you do get the concepts, I can recommend a reference website. The Mozilla foundation (same peeps that make FireFox) have an online resource called the Mozilla Developer Network (MDN).
if (a == b) // <== 2 (or 3) equal signs (comparison operators)
// do something
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
Your code is quite confused, and confusing. You specify that the function takes an input parameter named colorCode, but you never refer to it in the function. Your if/else clauses include the variable condition which is never defined anywhere. Finally you return the randomNumber for no reason I can see.
- The function does not need an input parameter, unless you want to pass it a random number. Assuming yo do not, then generate the number as the first step.
- The if statements only need to be as follows
- 1: If the value is less than 10 set colorCode to "green"
- 2: Else If it is less than 50 set colorCode to "yellow" (we already know it is not less than 10)
- 3: Else set it to "blue" (it must be 50 or greater)
- return colorCode to the caller of the function.
I got a warning that "colorCode" doesn't exist. And true, it doesn't. That makes it confusing, because there's two options. Let's forget them for a second. Try the code I gave you, vary the number. It writes to the console also.
Member 15708114 wrote:
I know that I have to use the Math.floor and Math.random to create a random number and the if and return operators but I think im messing up the order. Please help anyone.
You creating a random number inside the function. You want to "pass" it to the function as an argument.
So you don't see where on thing starts and the other ends? It's called "scope". Ask your teacher. Once clear, ask to step.
It executes one line, shows result in debug. That way you see how the computer "steps" through your instructions.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.