Prompt command


#1

Hello, I am working on the Rock Paper Scissors task and have completed it with one concern outstanding. While it is set up to allow the player to update what they want in the code for their choice of selection, there is no option to run the program and put up a window for the player to enter their choice through the keyboard whilst the program is running… In the past, I have used the “prompt” command for this. However, it doesn’t seem to want to work on this current version being used for the tutorial. The video does’t use it either, and I am keen to understand how we ca get strings in from the keyboard, if not through “prompt”.

Thanking you

Colin

https://www.codecademy.com/courses/learn-javascript/projects/rock-paper-scissors

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

I


#2

The exercise expects us to hard code the input value in our call expression. If you are wishing to explore this program once you complete the project, then copy the code over to your own machine and create an input function. prompt is the only way to get user input from the console.


#3

So in codecademy.com, the prompt command won’t work? Do you have a recommendation for software to put on my machine to run the code in?

Thanking you for the rapid response.

Colin


#4

It could be that for this exercise it is disabled.

 var userChoice = prompt('Do you  choose rock, paper or scissors?');
                   ^

ReferenceError: prompt is not defined

As long as you have a text editor and a browser you don’t need anythng else.

Create a CC folder in your documents directory, and a JavaScript folder inside that one.

You can be clicks away from a blank canvas in the JavaScript console of your browser. Every browser has an about:blank page. Open a new window and paste or type that into the location bar and hit Enter. Bookmark it on your bookmarks bar for quick access (Chrome allows this). Test the bookmark. You should be looking at a blank white page.

Now right click the page and Inspect Element. You’ll see the HTML and CSS for the page. Click console in the menubar and you will have a command prompt at the ready.


#5

Thank you for the prompt feedback Roy. Was very helpful.

Not sure if you can pass this feedback on. With last year’s changes to make more sections come under the Pro package, it is also a concern that some of the capabilities have been removed that previously provided an interactive capability that allowed students to run rock-paper scissors with the pop-up window from within Codecademy.com. This assisted the students understanding whilst going through the tutorials without the need to move outside Codecademy.com.

Once again thank you for your support on my initial enquiry.


#6

The free side of the pay wall has been in limbo since forever, and will likely remain so for the time being. There is talk of changes in the new year (Python 3, perhaps?). Something for our wish list.

As rock, paper, scissors goes, you can run the code on your own machine and write the prompt into the program. Dig around and you may find one or two of my suggestions on this topic.

If you need help running JS on your own machine, just ask, and we can walk you through a couple of different approaches (console, html).