View on GitHub

reading-notes

Reading notes for Code 102.

Javascript

Duckett Intro + Scripts 1-24

refresh

Concepts of Computer Programming

What is a script and how do I create one?

How do computers fit in with the world?

How do I write a script for a web page?

What is a script and how do I create one?

ex. from Duckett book

Customers can have a name added to the plaque; each letter costs $5. When a user enters a name, show the how much it will cost.

Next, break it into a series of tasks that have to be performed in order to achieve the goals:

1. The script is triggered when the button is clicked. 
2. It collects the name entered into the form field. 
3. It checks that the user has entered a value.
4. If the user has not entered anything, a message will appear telling them to enter a name.
5. If a name has been entered, calculate the cost ofthe sign by multiplying the number of letters by the cost per letter.
6. Show how much the plaque costs.

Expressions and Operators 74 -79

arithmetic operators name | operator —- | —— addition | + subtraction | - division | / multiplication | * increment | ++ (adds one to current number) decrement | – modulus % | divides two values and returns remainder

string operators

Functions 88-94

functionkeyword functionname() {
    document.write('Hello!');
}

function askUserForName(){ var userName = prompt(“Please enter your name: “); alert(“Hello”+ userName); return userName; } var userName = askUserForName ();

<= Back