generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Club Houses » Let's Make a Deal
Home Search
 

Re: JAVASCRIPT KIDDIES HALP // offr on 243 R$!

Previous Thread :: Next Thread 
RetroHat is not online. RetroHat
Joined: 22 Oct 2011
Total Posts: 12347
06 Dec 2014 02:52 PM
ot: offers on 243 R$
---------------------
Game works perfectly, but how do I make it so the answer isn't caps sensitive?

Ex.

If I picked "rock", the game would work out perfectly.

If I picked "ROCK", the game wouldn't work out as perfectly because it is caps sensitive.

--------------

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if (computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
}
console.log("Computer: " + computerChoice);


var compare = function(choice1, choice2) {

if (choice1 === choice2) {
return "The result is a tie!"
} else if (choice1 === "rock") {
if (choice2 === "scissors") {
return "rock wins"
} else {
return "paper wins"
}
} else if (choice1 === "paper") {
if (choice2 === "rock") {
return ("paper wins")
} else {
return "scissors wins"
}
}
};

compare(userChoice, computerChoice)
Report Abuse
curve8900 is not online. curve8900
Joined: 23 May 2009
Total Posts: 4401
06 Dec 2014 02:56 PM
1
Report Abuse
Coinman001 is not online. Coinman001
Joined: 10 Apr 2012
Total Posts: 56149
06 Dec 2014 02:57 PM

var e1 = "Hello World!";
var e2 = str.toLowerCase();
also send trades / 59k/??
Report Abuse
xSQLi is not online. xSQLi
Joined: 31 Oct 2014
Total Posts: 633
06 Dec 2014 02:58 PM
nice codecademy m8
Report Abuse
curve8900 is not online. curve8900
Joined: 23 May 2009
Total Posts: 4401
06 Dec 2014 02:58 PM
where do i add that @ coin

on top?
Report Abuse
Coinman001 is not online. Coinman001
Joined: 10 Apr 2012
Total Posts: 56149
06 Dec 2014 02:58 PM
use answer.toLowerCase();

also send trades / 59k/??
Report Abuse
curve8900 is not online. curve8900
Joined: 23 May 2009
Total Posts: 4401
06 Dec 2014 02:58 PM
@xsql

thx
i am like 1/4 of the way done
Report Abuse
Coinman001 is not online. Coinman001
Joined: 10 Apr 2012
Total Posts: 56149
06 Dec 2014 02:59 PM

var userChoice = prompt("Do you choose rock, paper or scissors?");
userChoice = userChoice.toLowerCase();
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if (computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
}
console.log("Computer: " + computerChoice);


var compare = function(choice1, choice2) {

if (choice1 === choice2) {
return "The result is a tie!"
} else if (choice1 === "rock") {
if (choice2 === "scissors") {
return "rock wins"
} else {
return "paper wins"
}
} else if (choice1 === "paper") {
if (choice2 === "rock") {
return ("paper wins")
} else {
return "scissors wins"
}
}
};

compare(userChoice, computerChoice)
also send trades / 59k/??
Report Abuse
curve8900 is not online. curve8900
Joined: 23 May 2009
Total Posts: 4401
06 Dec 2014 03:01 PM
your a genius coin thx
Report Abuse
Acmic is not online. Acmic
Joined: 04 Oct 2008
Total Posts: 47963
06 Dec 2014 03:05 PM
!!answer.match(/rock/i)
Report Abuse
curve8900 is not online. curve8900
Joined: 23 May 2009
Total Posts: 4401
06 Dec 2014 03:06 PM
@dylan

other one looks simpler

;C
Report Abuse
Acmic is not online. Acmic
Joined: 04 Oct 2008
Total Posts: 47963
06 Dec 2014 03:10 PM
Well, people are humans

Cant expect them to be as perfect as a computer

With the other one:

>inputs "Rock "

>breaks because of the space

With mine anything including the word "rock" is taken as rock

And it u needed it to be specifically rock, paper, or scissors

userChoice = (!!userChoice.match(/rock/i) ? "rock":!!userChoice.match(/paper/i) ? "paper":"scissors")
Report Abuse
Coinman001 is not online. Coinman001
Joined: 10 Apr 2012
Total Posts: 56149
06 Dec 2014 03:13 PM
@dylan

userChoice.indexof("rock")

ik i didnt captialized indexof corect but watevr

also send trades / 59k/??
Report Abuse
curve8900 is not online. curve8900
Joined: 23 May 2009
Total Posts: 4401
06 Dec 2014 03:14 PM
ya i was going to like try and make something like

if (userChoice =/= "rock","paper","scissors")
{
prompt("Do you choose rock, paper or scissors?")
}

idk how to make a not equal sign though =/= doesnt work

but acmin why are there those like "!!" and crap and /i and stuffz

Report Abuse
Acmic is not online. Acmic
Joined: 04 Oct 2008
Total Posts: 47963
06 Dec 2014 03:14 PM
dont u mean if(userChoice.toLowerCase().indexOf("rock") > -1)

isnt !!userChoice.match(/rock/i) a lot simpler?
Report Abuse
Sinblade is not online. Sinblade
Joined: 14 Aug 2010
Total Posts: 2782
06 Dec 2014 03:15 PM

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);
var compare = function(choice1,choice2){
if (choice1 === choice2){
return("The result is a tie!")
}
else if (choice1 === "rock"){
if (choice2 === "scissors"){
return("Rock Wins!")
}
else {
return("Paper Wins!")
}
}
else if (choice1 === "paper"){
if (choice2 === "rock"){
return("Paper Wins!")
}
else{
return("Scissors Win!")
}
}
}
compare(userChoice, computerChoice)

calculators are for dummies
Report Abuse
Coinman001 is not online. Coinman001
Joined: 10 Apr 2012
Total Posts: 56149
06 Dec 2014 03:15 PM

no cuz idk how to do that !!aduiwhaw:"" thing
also send trades / 59k/??
Report Abuse
Acmic is not online. Acmic
Joined: 04 Oct 2008
Total Posts: 47963
06 Dec 2014 03:19 PM
Not sure how to explain the !!, it turns anything into a boolean

the i means case-insensitive
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Club Houses » Let's Make a Deal
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image