Presentation is loading. Please wait.

Presentation is loading. Please wait.

Writing JavaScript Code

Similar presentations


Presentation on theme: "Writing JavaScript Code"— Presentation transcript:

1 Writing JavaScript Code
Mr Peake 22 September 2016

2 Writing JavaScript code
The State of the Art By now, most of you have: Explained how you ran the sample program Performed a tag by tag breakdown of the sample program in the style requested IF YOU HAVE NOT FINISHED: Please see me during this lesson and we can arrange a time for a catch-up session to help complete your work. 22/09/2016 Writing JavaScript code

3 Writing JavaScript code
Moving on You now need to plan, implement, test and demonstrate some JavaScript code of your own. This isn’t actually too hard at all, and the first script, Task 2, will be straightforward for all of you to complete. The research methods using W3Schools.com are about to pay off. 22/09/2016 Writing JavaScript code

4 Writing JavaScript code
Here’s the brief As is the case with most programming languages, in JavaScript you can use arrays in order to store multiple values under the same identifier. For example, an array of products can be set up as below for use on an ecommerce web site: var products = ["Printer","Tablet","Router"]; (i) Set up an array to include the items shown above, plus a few extras of your choice. (ii) Write a script that: • outputs the items in alphabetical order • counts the number of items in the array. In each case, plan, implement, test and demonstrate the scripts. 22/09/2016 Writing JavaScript code

5 Let’s take a look at JavaScript arrays
W3schools is really useful here: You are strongly advised to go to the JavaScript array reference using the REFERENCES link at top right of the screen. 22/09/2016 Writing JavaScript code

6 Looking at the array’s Methods:
You will find there is a sort method. 22/09/2016 Writing JavaScript code

7 Now let’s look at the sort Method
Read and document the sort method, and look at the Try It yourself code. This gives you the scope to see working code which you can then modify and test. 22/09/2016 Writing JavaScript code

8 Try It yourself – given code
22/09/2016 Writing JavaScript code

9 Try It yourself – modified code
22/09/2016 Writing JavaScript code

10 And full screen before…
22/09/2016 Writing JavaScript code

11 Writing JavaScript code
… and after. 22/09/2016 Writing JavaScript code

12 Before we write this up…
Research arrays, sort and whatever Property or Method with count the elements in the array. This is all available through the array reference on W3schools. If you want to get ahead, you should add your research into arrays into your 452 document after starting a new section called Task 2. Experiment with arrays by Putting the required values into an array (including extra ones) Output in alphabetical order Count the elements in the array. BE SURE TO KEEP A COPY OF YOUR CODE IN A NEW HTML DOCUMENT. 22/09/2016 Writing JavaScript code


Download ppt "Writing JavaScript Code"

Similar presentations


Ads by Google