charlottevef.blogg.se

Duke learn to program simpleimage script
Duke learn to program simpleimage script







duke learn to program simpleimage script
  1. #Duke learn to program simpleimage script how to
  2. #Duke learn to program simpleimage script code

And we'll say, we want y to be the result of calling square of 5, say. And we'll go ahead and make a new assignment to y. This is just a generic name that I've chosen to refer to any value that you pass in when you call square. And you'll also notice here that the fact that I used a variable named x doesn't have anything to do with this variable named x up here. That's again an attempt to help you by filling in that stuff. You'll notice that when I put in that initial brace that it put one in for me, kind of filling that out. So I'm going to say the square of x is what happens when you multiply x by itself and you get that result. I'm going to write a very small function that simply squares whatever value is passed in. So that starts with the function keyword and then we can give it whatever name we want. Let's do something a little more complicated. So the result of 3 x 3 is going to be 9 which is just like what we'd expect.

#Duke learn to program simpleimage script code

And when I run it, when I press the Run Code button down here, I see the results over here in the See It window. And now I want to see the result of that computation, see if I've actually done something that is going to be what I expect. And I'm going to give that a value, As well, that's dependent upon x. Then I'm going to create another variable. The first thing I'm going to do is simply create a variable, name it x, and give it an initial value. So let's start writing some code and playing with it and just sort of seeing what happens. We've done that because we believe that it provides a better environment. This is what we've created for you to help you learn to do your JavaScript programming. Welcome to the Duke Learn to Program environment. Lastly, most programmers use environments like this to make the tasks of programming easier, whether it is CodePen, BlueJ, which we'll introduce when you learn Java in the next course, or. These pages are also set up to be preloaded with images and pseudocode for the problems that you can work on so that you have a good point to get started from.

#Duke learn to program simpleimage script how to

For this course, later we'll look at how to use them in CodePen. Of course, if you want to use them for your Web pages that you make elsewhere, you could import the libraries and use them in any Web page you build. These libraries make it easier to manipulate images without a bunch of nitty-gritty JavaScript knowledge. Instead, they are libraries that we have set up for you so that you can solve interesting problems earlier in your learning. Speaking of SimpleImage and SimplePixel, these are not standard JavaScript libraries. These make it easier to see your output and can also help you debug. We have also set it up so that you can print a variety of things, such as SimpleImages and SimplePixels. This will make it easier to fix syntax errors in your code or to find and fix problems. Okay, so why use rather than just writing your code in CodePen? For one, we have set up the Duke Learn To Program environment to give you more friendly error messages. In fact, if we had finished this code before we hit the run code, you'd see Drew and Robert appear with their dinosaurs. But if you were to finish this code, as we will do soon, the output would show up on the right here. Here, the code is not finished so not much would happen.

duke learn to program simpleimage script

If you click on this button at the bottom, it will run this code. This is a page for the green screen algorithm, where the box to write code is on the left, is preloaded with the algorithm that we have developed together in a previous video. Here, you can see a screenshot of the web environment for developing JavaScript code. If you want to write JavaScript for a Web page somewhere else, you can always use this environment to develop, your code then copy it into your Web page later. However, for getting you started, we have a slightly more novice friendly environment, which we hope will help you write and debug your code more easily. If you use some other tool to write a Web page, you can generally write JavaScript code in your Web page easily, though the specifics will depend on the tool. In CodePen, you can write JavaScript in the right frame, which we have highlighted here. Now that you're learning a bit about JavaScript, you might wonder where you would write it, or how you would run it.









Duke learn to program simpleimage script