This forum is now read-only. Please use our new forums! Go to forums
A newbie question?HELP!
Instructions is:1.Under your previous code, declare a variable called computerChoice and make it equal to Math.random(). 2.Print out computerChoice so you can see how Math.random() works. This step isn’t needed for the game - just useful for learning! my code is:var userChoice = prompt(“Do you choose rock,paper or scissors?”); var computerChoice = Math.random(); console.log = (computerChoice); I hit Save&Submit code,But,But it says:“Oops, try again! Did you remember to log computerChoice to the console?” Thus,I am very confused,HELP!
Answer 51ff5f2f80ff33134b005775
Answer 51ff711b548c359e2f005d64
Well as far as I can see from the track, you should know about functions already, do you? Well console.log is a function, well actually only log is the function and console the structure which contains it but lets not bother about this yet, you’ll get to know objects in a later course. So as all other functions you call it by appeding () with the parameters inside. What
console.log = ()
does is that it overwrites the variable. e.g.
var print;
print = function(para){
console.log(para);
}
print("test"); //--> test
print = 42;
print()// --> error print is not a function
console.log(print)//--> 42
So to say you change the value of the variable from a function to the string you wanted to print and this behavior is not limited to codecademy or this game.
1 comments
@haxor789:I got it.Thanks,sir!
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
1 comments
@haxor789:Thanks,sir.I tried as you say,It runs well,But I have a new confuse, as you say what should I distinguish “console.log()” with “console.log = ()”.Or it’s just difference in the special codecademy “game”,Please.