Computer choice part 1


#1

It doesn't seem to work for me:
var userChoice = prompt("Do you choose rock, paper or scissors?")
var computerChoice = Math.random()

console.log = computerChoice

It prints computerChoice but then gives me an error asking if I logged computerChoice in the console.


#2

This is how you log an example:

console.log("Chicken")

So if i implement that structure to your code:

console.log(computerChoice)

#3

The console has a feature where the last value used in a code is shown on the console. You probably used it in one of the first exercises before console.log was introduced. That is what is happening here you see the value of this assignment:

console.log = computerChoice

Now the big problem is that this in fact an assignment meaning you thereby replaced the "print to the console"-ability of console.log with a random number. So even if you fix this the interpreter will tell you "number is not a function" or something like this. So in addition to what @amanuel2 already said you need to refresh the page after fixing in order to reset console.log to its built-in functionality.


#4

Thanks, the refreshing did the trick, I tried it before and it didn't work so that's what fixed it :smile: