Don't get the right return answer 7/9, 8/9, 9/9


#1

Below you see my code. It's perfectly fine and it works, EXCEPT that I get an return answer for the computerChoice, BUT DON'T get an answer like: paper wins, rock wins, or scissors wins.
What am I doing wrong? Or is it something in the editor?
(and off-topic: what am I doing wrong in posting my code?)

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 {("scissors wins");
        }
    }

    else if (choice1 === "scissors"){
        
        if (choice2 === "rock"){
            return ("rock wins");
        }
        else {("paper wins");
        }
    }
}

#2

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);

The console.log on the last line is where your computerChoice notification comes from and the reason you don't see the winner is because you don't call the function yet:

console.log(compare(userChoice,computerChoice));

PS: About the formatting there are several ways to do it you can mark and press teh </> button you can indent a line with 4 spaces you can use a back tick ` at the beginning and the end of your code and you can use 3 backticks at the line before the start and the line behind the end to make it that colourful. Have a look at your text to see what I've changed. Good Luck!