The Furry Forums would like to place cookies on your computer to help us make this website better. To find out more about the cookies, see our privacy notice.
To accept the cookie click here, or please login or register.

Author Topic: Help with JavaScript?  (Read 946 times)

0 Members and 0 Guests are viewing this topic.

Offline Georgisaur

  • Avid Aardvark
  • *
  • awards This user has been a forum member for over 10 years
  • Posts: 39
    • Awards
  • Species: Wolf
  • Coloring: Brown
  • Height: 5"11
Help with JavaScript?
« on: June 25, 2013, 02:33:36 PM »
I can't for the life of me figure out where I've gone wrong! Help?!
http://pastebin.com/qsnqyLST

Offline WingedZephyr

  • Monochromatic Friend
  • Administrator
  • Zoomorphic Zebra
  • ******
  • awards Assigned to someone who is observed to be very friendly toward other members (frequently welcoming people in the Intro board, answering questions, etc.) Obtainable by request This user has been a forum member for over 10 years This user has donated to the forum.
  • Posts: 8353
  • Gender: Female
    • Skype
    • Steam
    • Discord
    • Fur Affinity
    • DeviantArt
    • My art and characters
    • Awards
  • Species: Cagon (cat/dragon hybrid)
  • Coloring: White with black "glove" markings and grey stripes
  • Height: 4' 6" (feral)
  • Build: small, lean
  • Reference: [link]
Re: Help with JavaScript?
« Reply #1 on: June 25, 2013, 05:36:49 PM »
From what I can tell (and I'm not the best at Javascript, so I might be wrong or missing something) - your script works, but the console.log() command at the end is putting the answer into the JavaScript console log. If you're not looking at the console, it looks like there isn't an answer at all, so if you wanted the answer to come up in a prompt window sort of thing, you'd have to use alert() instead of console.log().


Edit: Also forgot, the variables that you're using at the end are incorrect. You should be comparing the user and computer choices, not choice1 and choice2.

So, combined with the previous stuff I said, if you want the answer to come up as an alert, you'd be changing the console.log(compare (choice1, choice2)) to alert(compare (userChoice, computerChoice)). You could still keep the answer recorded in the console log if that's what you wanted to do, but either way the variables need to change for it to work.
« Last Edit: June 25, 2013, 05:42:07 PM by WingedZephyr »
  • Avatar by: Ladie


Art stream:


** Art commissions currently open **
.: [Prices] :: [To-do list] :.
.: IMVU :: FurAffinity :: DeviantArt :: My website :.

Offline Georgisaur

  • Avid Aardvark
  • *
  • awards This user has been a forum member for over 10 years
  • Posts: 39
    • Awards
  • Species: Wolf
  • Coloring: Brown
  • Height: 5"11
Re: Help with JavaScript?
« Reply #2 on: June 25, 2013, 06:30:58 PM »
Thank you! It was because I put console.log(compare (choice1, choice2)) instead of console.log(compare (userChoice, computerChoice)).
I really am a silly fur!  XD


Offline WingedZephyr

  • Monochromatic Friend
  • Administrator
  • Zoomorphic Zebra
  • ******
  • awards Assigned to someone who is observed to be very friendly toward other members (frequently welcoming people in the Intro board, answering questions, etc.) Obtainable by request This user has been a forum member for over 10 years This user has donated to the forum.
  • Posts: 8353
  • Gender: Female
    • Skype
    • Steam
    • Discord
    • Fur Affinity
    • DeviantArt
    • My art and characters
    • Awards
  • Species: Cagon (cat/dragon hybrid)
  • Coloring: White with black "glove" markings and grey stripes
  • Height: 4' 6" (feral)
  • Build: small, lean
  • Reference: [link]
Re: Help with JavaScript?
« Reply #3 on: June 25, 2013, 08:53:40 PM »
No problem. :P
  • Avatar by: Ladie


Art stream:


** Art commissions currently open **
.: [Prices] :: [To-do list] :.
.: IMVU :: FurAffinity :: DeviantArt :: My website :.

 

Powered by EzPortal

anything