Unofficial Programming Thread V

Post » Thu Jun 20, 2013 5:54 pm

Previous threads:

http://www.gamesas.com/topic/1322056-unofficial-programming-thread-iv/
http://www.gamesas.com/topic/1166756-unofficial-programming-thread-iii/
http://www.gamesas.com/topic/1123394-unofficial-programming-thread-ii/
http://www.gamesas.com/index.php?/topic/1092028-unofficial-programming-thread/

I can't answer that either, not being familiar with Codecademy's Javascript course.

Average Porcupine didn't change your code, just formatted it better inside a script tag. We aren't here to give you the answer, but to help you. Giving you the answer won't help you in the long-run when it comes to a logic problem (if it was not knowing the specifics of a function, that's a different story). Give a man a fish and whatnot.

That's what you need to do.

It would look like that's the given code.

 var compare = function(choice1,choice2){	if (choice1 === choice2){		return ("The result is a tie!");	}	if (choice1 ==="rock"){		if (choice2 === "scissors"){			return "rock wins"; ?		}		else if (choice2 === "paper"){			return "paper wins";		}	}};
That's your code

1. It doesn't answer the questions asked (well, except the "tie" part.
2. Nested ifs, without a good reason, is generally frowned upon. Using logical is usually better.
3. Having an if/elseif without a final else is generally frowned upon as well.

You have the similar code for answering A and B, you just need to answer A and B.

Also, if you can't go back and instantly answer the previous part, then you should probably go back and re-answer it from scratch anyway just because you've probably not learned the previous lesson well enough yet.
User avatar
Olga Xx
 
Posts: 3437
Joined: Tue Jul 11, 2006 8:31 pm

Post » Thu Jun 20, 2013 4:28 am

I was seeking help not the initial answer but thanks!

EDIT: It's just confusing after a month of no lessons

EDIT 2: I got it!!

I just rearranged the words around and it worked

User avatar
Nuno Castro
 
Posts: 3414
Joined: Sat Oct 13, 2007 1:40 am


Return to Othor Games