I tried creating my own R,P,S, but I think this code does not seem to be working in my browser


#1

Someone help me debugging this:
I tried creating my own R,P,S, but I think this code does not seem to be working in my browser. Help.

var usrChc = prompt('Choose Rock, Paper, Scissor?');
var cmpChc = Math.random();

if (cmpChc < 0.34) {
cmpChc = "Rock";
}
else if (cmpChc <= 0.67) {
cmpChc = "Paper";
}
else {
cmpChc = "Scissor";
}

console.log("You" + "-" + " " + usrChc);
console.log("V/S");
console.log("Computer" + "-" + " " + cmpChc);

var compare = function(usrChc, cmpChc) {
if (usrChc === cmpChc) {
console.log("Tie. Play again?");
var plyAgn = prompt('Play Again? Y/N?');
if (plyAgn === Y) {
window.open(Rock,Paper,Scissors.html);
}
else {
var fdBck = prompt('Rate me, on scale of 1-5');
if (fdBck <= 3) {
window.alert("I promise, next time, my game is gonna satisfy you.");
}
else if (fdBck <= 5) {
window.alert("Thanks. I will try even harder to satisfy you more");
} else {
window.alert("I think you had a hiccup or was it real? If it was real, thank you!");
}
}
}
else if (usrChc === "Rock") {
if (cmpChc === "Paper") {
console.log("You win.");
var plyAgn = prompt('Play Again? Y/N?');
if (plyAgn === Y) {
window.open(Rock,Paper,Scissors.html);
}
else {
var fdBck = prompt('Rate me, on scale of 1-5');
if (fdBck <= 3) {
window.alert("I promise, next time, my game is gonna satisfy you.");
}
else if (fdBck <= 5) {
window.alert("Thanks. I will try even harder to satisfy you more");
} else {
window.alert("I think you had a hiccup or was it real? If it was real, thank you!");
}
}
} else if (cmpChc === "Scissor") {
console.log("You lose.");
var plyAgn = prompt('Play Again? Y/N?');
if (plyAgn === Y) {
window.open(Rock,Paper,Scissors.html);
}
else {
var fdBck = prompt('Rate me, on scale of 1-5');
if (fdBck <= 3) {
window.alert("I promise, next time, my game is gonna satisfy you.");
}
else if (fdBck <= 5) {
window.alert("Thanks. I will try even harder to satisfy you more");
} else {
window.alert("I think you had a hiccup or was it real? If it was real, thank you!");
}
}
}
}
else if (usrChc === "Paper") {
if (cmpChc === "Rock") {
console.log("You win.");
var plyAgn = prompt('Play Again? Y/N?');
if (plyAgn === Y) {
window.open(Rock,Paper,Scissors.html);
}
else {
var fdBck = prompt('Rate me, on scale of 1-5');
if (fdBck <= 3) {
window.alert("I promise, next time, my game is gonna satisfy you.");
}
else if (fdBck <= 5) {
window.alert("Thanks. I will try even harder to satisfy you more");
} else {
window.alert("I think you had a hiccup or was it real? If it was real, thank you!");
}
}
} else if (cmpChc === "Scissor") {
console.log("You lose.");
var plyAgn = prompt('Play Again? Y/N?');
if (plyAgn === Y) {
window.open(Rock,Paper,Scissors.html);
}
else {
var fdBck = prompt('Rate me, on scale of 1-5');
if (fdBck <= 3) {
window.alert("I promise, next time, my game is gonna satisfy you.");
}
else if (fdBck <= 5) {
window.alert("Thanks. I will try even harder to satisfy you more");
} else {
window.alert("I think you had a hiccup or was it real? If it was real, thank you!");
}
}
}

} //Big paper else if close
else if (usrChc === "Scissor") {
if (cmpChc === "Rock") {
console.log("You lose.");
var plyAgn = prompt('Play Again? Y/N?');
if (plyAgn === Y) {
window.open(Rock,Paper,Scissors.html);
}
else {
var fdBck = prompt('Rate me, on scale of 1-5');
if (fdBck <= 3) {
window.alert("I promise, next time, my game is gonna satisfy you.");
}
else if (fdBck <= 5) {
window.alert("Thanks. I will try even harder to satisfy you more");
} else {
window.alert("I think you had a hiccup or was it real? If it was real, thank you!");
}
}
} else if (cmpChc === "Paper") {
console.log("You win.");
var plyAgn = prompt('Play Again? Y/N?');
if (plyAgn === Y) {
window.open(Rock,Paper,Scissors.html);
}
else {
var fdBck = prompt('Rate me, on scale of 1-5');
if (fdBck <= 3) {
window.alert("I promise, next time, my game is gonna satisfy you.");
}
else if (fdBck <= 5) {
window.alert("Thanks. I will try even harder to satisfy you more");
} else {
window.alert("I think you had a hiccup or was it real? If it was real, thank you!");
}
}
}
} //Big scissor else if close
};
compare(usrChc, cmpChc);


Please help me with this code for rock paper game
#2

Do you consider it to be working somewhere other than in your browser? If so, where is this other place and how are you running it in your browser, and which browser?

You'll have to consider which behavior isn't working and figure out which part of the code that corresponds to. You might want to look very closely at that part and/or add prints to the console to investigate what's happening there.


#3

console.log log something to the console, the console is generally used for debug purposes, you might want to consider to use something else, a good solution would be to make a div, give it an id, use getelementbyid and innerhtml, to display output