Aurifex Labs LLC

Programming in 10 short lessons

1) Functions do things. You call functions.

printHelloWorld()

2) Functions can take arguments, and return values.

print("This is an argument.")
    
print(random())
    

3) You can define functions that do new things.

function randomInt(min, max) {  
    return floor(random() * (1 + max - min) + min)
}

print(randomInt(3, 9))
    

4) Most operators are just functions with special symbols.

print(7 + 5)
print(add(7, 5))
    

5) You can assign a value to a variable.

var a = 6
print(3 * a)
    

6) Conditionals allow some things to happen and not other things.

if(random() > 0.5) {
    print('Heads')
}

else {
    print('Tails')
}
    

7) Loops make things happen more than once.

for(var i = 0; i < 3; i++) {
    print("loop")
}
        
for(var i = 0; i < 5; i++) {
    print(i)
}

    

8) Values have types like number, string, and boolean. Comments don't get run.

// n is a number. This is a comment.
var n = 10

// name is a string.
var name = "Asha"

// done is a boolean. Booleans can be true or false.
var done = true

if(done) {
    print(name + " is learning to program in " + n.toString() + " minutes." )
}
    

9) Arrays contain multiple values and are ordered. You can lookup and assign an item in an array by its index. You can also loop over an array.

var names = ['Steve', 'Miranda', 'Jen', 'Lincoln']

print(names[0])

names[2] = 'Jenn'

names.forEach(function(name) {
    print(name)
})
    

10) Objects can be used to store structured data. Values in an object are looked up and assigned by their key.

var person = {
    name: 'Bonnie',
    email: 'bonnie@aurifexlabs.com',
    logins: 13,
    isAuthenticated: true,
}

if(person.isAuthenticated) {
    print("You are logged in as: " + person.name + " (" + person.email + ")."
    person.logins += 1
}

else {
    print("Please log in.")
}
    

Great job!

These are the basic building blocks of programming. The key to learning programming is practice. There are patterns and details, but the core is right here.

If you want some help learning, go to aurifexlabs.com for information about training.

Want to keep going? Go on to web development in 10 short lessons.