Congratulations on making it to the end of the programming basics. You now have a good basic exposure to the sort of things you can do with computer programming.
The best way to develop programming ability is to use your skills. When you get stuck, try breaking the problem down into smaller pieces. If you’re still confused, you can usually find help online.
It is through this process of trying to make things and extending your knowledge that you develop expertise.
Also consider taking a look at some of our other courses.
Here is a quick reference with everything covered in this course.
And here is the javascript template from earlier, which you can save and edit to work with Javascript without needing to install anything new.
// Defining a variable
let myvariable;
// Defining and assining at the same time
let myvariable = 10;
// Old style, performs hoisting which is usually undesirable. Prefer let.
var myvariable = 10;
//
// Data Types
//
// Boolean values: true or false.
&& means and. true && true => true
false && anything => false
|| means or. true || anything => true
false || false => false
// Strings are used for text.
let str = "hello";
str.length; // gives 5
str[0]; // gives "h"
//
// Functions
//
// Functions take 0 or more inputs, and may optionally
// return a value.
// Common form
function add(a, b) {
return a + b;
}
// equivalent to
var add = function(a, b) {
return a + b;
};
//
// Conditionals
//
if (some condition) {
// do this thing
} else if (some other condition) {
// do this other thing
} else {
// do this if nothing else matched
}
//
// Loops
//
for (let i = 0; i < 10; i++) {
// do something as long as i < 10
}
let i = 0;
while (i < 10) {
// do something
// make sure to update i, or use break
// otherwise this will loop forever
i ++;
}
// A do loop always runs at least once.
let i = 0;
do {
// something
i -= 1;
} while (i > 0);
//
// Recursion
//
// Recursive functions need a base case to ensure they dont
// call themselves forever.
function fib(n) {
if (n < 2) {
return 1;
}
return fib(n-1) + fib(n-2);
}
//
// Arrays
//
let my_array = [2, 4, 6, 8];
my_array.length; // 4
my_array.push(10); // adds a value to the end
my_array[0]; // first value is 2
my_array[3]; // last value is 8
my_array[2] = 0; // Updating the array.
//
// Hash tables / Objects
//
// key : value
let my_table = { 'cat': 2, 'dog': 4};
Object.keys(my_table); // gives us an array we can loop over
my_table['cat']; // lookup a value
my_table['bird'] = 6; // add or update a value
delete my_table['cat']; // remove a value
Back to courses.