Need urgent help


#1

so i got it working but is there a way to make it print 3 different string based on a math random choise?

var userChoice = prompt("how are you feeling today on a scale from 1 to 10?");

if (userChoice == 1)
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "test1";
} else if(computerChoice <= 0.67) {
computerChoice = "test2";
} else {
computerChoice = "test3";
console.log("Computer: " + computerChoice);
}

can someone correct any mistakes i made? or explain what i did wrong


Need some help
#2

#3

this is how i solved it
var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();

if (computerChoice <= 0.33){
computerChoice = "rock";
}
else if(computerChoice >= 0.34 && 0.66){
computerChoice = "paper";
}
else{
computerChoice = "scissors";
}

hope it helps!!!


#4

thx! it helpen me out allot i finaly finished it!

heres the final product (the feelings meter)

one more thing how do i get this to work in for example brackets?

var userChoice = prompt("how are you feeling today on a scale from 1 to 10?");
var computerChoice = Math.random();
if (userChoice == 1) {
if (computerChoice <= 0.33){
computerChoice = "aww that sucks! hope you feel better soon";
}
else if(computerChoice >= 0.34 && 0.66){
computerChoice = "thats not nice to hear :frowning: hope you will cheer up soon!";
}
else{
computerChoice = "thats afwull! hope you have a nice day anyway!";
}
}

var computerChoice = Math.random();
if (userChoice == 2) {
if (computerChoice <= 0.33){
computerChoice = "aww that sucks! hope you feel better soon1";
}
else if(computerChoice >= 0.34 && 0.66){
computerChoice = "thats not nice to hear :frowning: hope you will cheer up soon1!";
}
else{
computerChoice = "thats afwull! hope you have a nice day anyway1!";
}
}

var computerChoice = Math.random();
if (userChoice == 2) {
if (computerChoice <= 0.33){
computerChoice = "ooh thats not good! heres a smiley for you! :)";
}
else if(computerChoice >= 0.34 && 0.66){
computerChoice = "to bad! cheer up it will get better!";
}
else{
computerChoice = "aww that terrible :frowning: thinks will get beter soon!";
}
}

var computerChoice = Math.random();
if (userChoice == 3) {
if (computerChoice <= 0.33){
computerChoice = "just hang in there things will get better";
}
else if(computerChoice >= 0.34 && 0.66){
computerChoice = "im here for you :slight_smile: to cheer you up with a smiley :)";
}
else{
computerChoice = "aww you can do better! cheer up";
}
}

var computerChoice = Math.random();
if (userChoice == 4) {
if (computerChoice <= 0.33){
computerChoice = "thats not so good. but hey thinks will get better soon :)";
}
else if(computerChoice >= 0.34 && 0.66){
computerChoice = "hmm thats not so nice to hear, cheer up champ!";
}
else{
computerChoice = "there are allot off people out there! your not alone";
}
}

var computerChoice = Math.random();
if (userChoice == 5) {
if (computerChoice <= 0.33){
computerChoice = "mwhaa could be better right :wink:";
}
else if(computerChoice >= 0.34 && 0.66){
computerChoice = "comon cheer up mate! your not alone!";
}
else{
computerChoice = "hang in there champ! thinks will get better";
}
}

var computerChoice = Math.random();
if (userChoice == 6) {
if (computerChoice <= 0.33){
computerChoice = "me too.. me too..";
}
else if(computerChoice >= 0.34 && 0.66){
computerChoice = "hey! thats not so bad, your day might get even better!";
}
else{
computerChoice = "hey thats not bad at all there are people out there doing worse!";
}
}

var computerChoice = Math.random();
if (userChoice == 7) {
if (computerChoice <= 0.33){
computerChoice = "nice! keep up the good vibes";
}
else if(computerChoice >= 0.34 && 0.66){
computerChoice = "hey you! you rock!";
}
else{
computerChoice = "keep it up! you might cheer up someone else with your good atitude :)";
}
}

var computerChoice = Math.random();
if (userChoice == 8) {
if (computerChoice <= 0.33){
computerChoice = "marvelous! keep it up!";
}
else if(computerChoice >= 0.34 && 0.66){
computerChoice = "thats so great to hear!";
}
else{
computerChoice = "ooh wauw! thats great to hear!";
}
}

var computerChoice = Math.random();
if (userChoice == 9) {
if (computerChoice <= 0.33){
computerChoice = "yeaah! great to see ur happy!";
}
else if(computerChoice >= 0.34 && 0.66){
computerChoice = "wonderfull! keep up the good vibes!";
}
else{
computerChoice = "hey there! did you know?.. you are awsome!";
}
}

var computerChoice = Math.random();
if (userChoice == 10) {
if (computerChoice <= 0.33){
computerChoice = "did you just win the lottery??";
}
else if(computerChoice >= 0.34 && 0.66){
computerChoice = "amazing! i hope you keep feeling this way!";
}
else{
computerChoice = "great! share your good vibes!";
}
}


#5

Mine says to capitalize Math.random but it already is capitalized. Why is this happening?