Prompt debugging
So far in all of our programming the user didn't input anything. That's all about to change right now. To get the users input we will use the prompt() command. The prompt() command enables us to interact with the user.
As we start building more complex things we're going to encounter problems. In programming language that is called bugs. Don't worry bugs - they are one of the most natural things in every programmer's day, and for that, we dedicate a few minutes to talk about it.
Video Transcript
00:00All right, hopefully you're starting to get really excited because we're starting to create really cool animations now
00:06Really really really important things we're going to be covering in this lecture
00:09One is we're going to look at how do we get input from the user this is going to be the first time we ask the user
00:15To help us to define our code or our animation by the end of this
00:20Lecture you're actually going to be able to fetch information from your user to create something custom just for them
00:25Beyond that
00:27Really great you're gonna see how do I deal with a bug and how should you deal with a bug because you're gonna face them?
00:32every single developer has them and
00:35Unfortunately, I think about 60 or 70 percent of every project is finding bugs and fixing them
00:40So it's a really important skill that we make sure we don't delete because I want you to be to see
00:46When I make a mistake so you could learn from my mistakes because that's the best time for you to learn and your mistakes are
00:51Even better. So whenever you hit a mistake and you can't solve it. That's where the comment box is for. So let's jump right in
01:00Let's go ahead and see
01:02Something cool in action a little bit more of interactivity added into our elements
01:07So I'm gonna go ahead and just set my times two instead of four because I don't want it to be so drastic the difference
01:14And when I want to go into my variable here in line 15 and change the value
01:20To a function called prompt
01:23Do a function called prompt?
01:37Open close round bracket and then the first property we're gonna say whatever copy we want to display the user
01:44And in this case we want to ask him how long will base?
01:50Animation be and we'll set the second parameter by putting a comma and then setting the initial basic value to be one
01:59Now don't again, don't worry about functions too much
02:01Although what we're actually doing is we're asking JavaScript to stop the interpretation of our script
02:07And prompt the user a question telling him basically displaying the user a question. How long will base animation will
02:15the base
02:17Animation be and then put a default value of one there and notice how I set this to be equals
02:24My animation time in other words, whatever the user will put in here will automatically be the value of an anim time
02:33So if I go ahead and I run my application again, you'll see that it's gonna prompt me and first of all
02:39There's a little little little itsy-bintsy error here
02:43You could see in our console lucky that we have jQuery and if we go ahead and open up our element
02:49We'll see that we have your some sort of small problem some sort of a hiccup
02:53So maybe we didn't type prompt correctly. So let's check that we wrote we wrote promote by mistake
03:00So it's gonna be prompt and and again, these are the issues
03:04You just have to figure them out in our case. I misspelled the word prompt and
03:08Because of that it didn't work
03:10So I'll just click here at save and go back into my browser and click on refresh
03:14Mm-hmm, and now you'll see I'm faced with a question before anything happened
03:19It's asking me how long will the base animation be the default value here is one
03:24But if I set it to be let's say zero dot five
03:29We'll say that all our animations will be really quick if I refresh again
03:33But this time put here may be four and run it
03:36We'll see that my animation will take four seconds to the top one eight seconds for this middle tier one and 12 seconds for our
03:45Item here or it's a 16 seconds actually, so it's if it's four eight sixteen
03:52So this is how we add a little bit of user and interactivity where we could ask the user to input some information
03:58That we want them to put inside. So that's one way of doing that. This is our first user
04:04Defined user interaction that we've created
04:07And that's it. This is this is all we wanted to talk about
04:11Regarding numbers really at this stage in the following video. We're gonna talk about in the following lecture
04:17We're gonna go back into strings and see how strings are very very similar to numbers in that way
04:25Really? How do we actually combine things inside of strings? We're gonna look at that immediately in the following lecture
