Android/GogoTraining/Programming for Non-Programmers with JavaScript
Description
Learning to program is both fun and easy by taking this brand new and exciting Introduction to Programming for Non-Programmers course! Not only will you learn the foundations of how to program, but you’ll also gain a solid foundation in the world’s most popular computer language: JavaScript. Without having to install any special software, and using only your web browser and your text editor, you’ll journey into the exacting world of programming. Using an easy to learn training style, you’ll learn about the JavaScript language, functions, variables, making decisions, looping, and more. At the end of the course, you’ll be in a great position to take other introductory programming language course.
Prerequisites
The only prerequisite is a basic familiarity with computers, along with an eagerness to learn programming. You do not need any programming experience.
Objectives
As a result of taking this course, you will be able to: • Write programs to display output messages • Write programs to prompt for input • Use variables to store information • Write programs to make decisions • Write programs to repeat a sequence of operations
Outline
Module 00: Course Introduction
Module 01: Introduction to Programming
- What is a computer language?
- Why should you learn a computer language?
- What computer language should you learn first?
- Demo: Let's Make our First Statement in JavaScript!
- Lab Exercise: hello.html
Module 02: Introduction to JavaScript
- JavaScript Advantages
- Web Browser and JavaScript
- .html File Extension
- Editing hello.html
- // and /* … */
- Demo: Hello World
- Lab Exercise: Hello World
Module 03: Functions Part 1
- About Functions
- alert() w/o input parameter
- Semicolon
- alert() w/Input parameter
- Strings
Module 04: Functions Part 2
- Defining Functions without inputs
- Defining Functions with inputs
- Returning values from Functions
- Demo: Using the Alert Function
- Lab Exercise: Using the Alert Function
Module 05: Variables
- JavaScript Variables
- var keyword
- String variables
- Number variables
- Operators: +, -, *, /
- Confirm Function
- true, false
- prompt() Function
- Demo: Using Variables
- Lab Exercise: Using Variables
Module 06: Making Decisions
- if statement
- if else statement
- confirm() with if statement
- confirm() with if-else statement
- Compare Operators: ==, <. >, <=, >=
- if-else-if…
- Demo: Making Decisions
- Lab Exercise: Making Decisions
Module 07: Repeating Steps
- Repeating fixed number of times
- Repeating variable number of times
- while statement
- while statement with prompt()
- Checking for null
- Demo: Repeating Steps
- Lab Exercise: Repeating Steps
Module 08: Course Summary
- Put All Skills Together To Write a Javascript App
- Review the key concepts
- Write a temperature conversion script!
00: Course Introduction- Programming for Non-Programmers with JavaScript
Common languages:
- C
- Java
- Perl
- Python
01: Introduction to Programming
Scripting Languages vs Compiled Languages
test.html:
<script> alert("hello"); </script>
Don't forget the semicolon!
02: Introduction to JavaScript
Script tags:
<script> </script>
Comments:
// single line /* multi line comment */
03: Functions Part 1
alert();
A ";" terminates each statement
String:
"text" 'text'
04: Functions Part 2
Code that will be reused should be made into a function
function sayHello() { alert("hi"); } sayHello();
function sum(a, b) { return a + b; } alert("sum: " + sum(10,20));
05: Variables
var answer; var name = "joe"; var number = 10; var msg = name + " has " number + "\n"; alert(msg);
note: 'var' is optional, but best practice
Confirm() function to get a Cancel/OK option.
# returns: true / false var answer = confirm("Do you want to continue?");
06: Making Decisions
if/else:
answer = confirm("continue?"); if (answer) { ... } else { ... }
Operators:
== < > <= >=
Prompt:
answer = prompt("how many?"); if (answer == null) { ... } // if no answer given
07: Repeating Steps
while (true) { if (...) { break; } }
08: Course Summary
<script> // This is a single line comment /* This is a multiline comment */ </script>
<script> // This will display an alert alert(); </script>
<script> // Define a custom function to add two numbers function sum(a, b) { return a + b; } // Call the custom function alert(“sum: “ + sum(10,20)) </script>
<script> // Declare a variable called name var name; // Prompt the user to enter their name name = prompt(‘Enter your name’); // Create a variable called msg (for message) var msg = ‘Hello ‘ + name; // Display alert alert(msg); </script>
<script> var number; number = prompt(‘Enter a number’); var msg; if (number == 100) { msg = ‘Your number was 100’; } else { msg = ‘Your number was NOT 100’; } alert(msg); </script>
<script> while (true) { msg = ‘Pick a number between 1-100’; answer = prompt(msg); if (answer == null) { answer = confirm(‘Exit app?’); if (answer) { exit(); } continue; } if (answer == 42) { break; } alert(‘Try again’); } </script>
function toC(f) { return (5/9) * (f - 32); }