Turning Learners Into Developers
Codekilla
CODEKILLA
// programming.concepts.lab

Codekilla Programming Lab.

Master programming fundamentals through guided walk-throughs, workflow diagrams, and runnable code examples. Every concept you need before your first real project.

ch. 01

Introduction to Programming

Understanding the fundamentals of how computers execute instructions

Programming is the process of creating instructions that a computer can execute to perform specific tasks. It's like writing a recipe, but for computers. Programs flow through four stages: writing code, translating that code to machine form (compilation or interpretation), executing it on the CPU, and producing output — whether that's a value on screen, a file on disk, or a network response.

  1. Write Code — developer creates source code in a programming language
  2. Compilation / Interpretation — code is translated to machine-readable format
  3. Execution — CPU processes the instructions
  4. Output — program produces results (screen, file, network…)
Procedural
Step-by-step instructions
Object-Oriented
Objects & classes
Functional
Pure functions
Declarative
What, not how
try.it()
javascript
// Hello, World! in JavaScript
console.log('Hello, World!');
ch. 02

Variables

Containers for storing data values that change during execution

A variable is like a labelled box that holds a value. You can store data, read it, and change it later. Lifecycle: declaration (reserve memory) → initialisation (first value) → usage → modification.

  1. let name; // Declaration
  2. name = 'Ashok'; // Initialisation
  3. console.log(name); // Usage
  4. name = 'Codekilla'; // Modification
try.it()
javascript
let message = 'Hi!';
let count = 0;
count = count + 1;
console.log(message, count); // Hi! 1
ch. 03

Constants

Immutable values that can't be changed after initialisation

A constant is a name bound to a value that cannot be reassigned. Use `const` when the reference is fixed — like mathematical values, config keys, or lookup tables.

FeatureVariable (let)Constant (const)
Can be reassigned?YesNo
Must initialise?OptionalRequired
Use caseValues that changeValues that stay fixed
try.it()
javascript
const PI = 3.14159;
const TAX_RATE = 0.18;
// PI = 3;  // TypeError: Assignment to constant
ch. 04

Data Types

Different kinds of data that can be stored and manipulated

Programming languages work with a small set of primitive data types that combine to form rich data structures. Knowing when to reach for each keeps your code correct and efficient.

Number
42, 3.14
String
'Hello'
Boolean
true / false
Undefined
undefined
Null
null
Object
{ key: 'val' }
try.it()
javascript
let age = 24;        // number
let name = 'Ada';    // string
let active = true;   // boolean
let data = null;     // null
ch. 05

Operators

Symbols that perform operations on values and variables

Operators are the verbs of a language — they do things.

TypeOperatorsExampleResult
Arithmetic+ - * / %10 + 515
Comparison== != < > <= >=10 > 5true
Logical&& || !true && falsefalse
Assignment= += -= *= /=x += 5x = x + 5
try.it()
javascript
const a = 7, b = 2;
console.log(a + b);   // 9
console.log(a / b);   // 3.5
console.log(a > b);   // true
ch. 06

Comments

Documentation inside code that's ignored by the compiler

Comments explain intent. They help future-you, your teammates, and reviewers understand *why* the code does what it does — not *what* it does (the code itself already says that).

Single line
// one line comment
Multi line
/* many lines */
JSDoc
/** @param {string} x */
try.it()
javascript
// TODO: cache this once API is stable
function greet(name) {
  /* Capitalise the first letter for a friendlier tone */
  return 'Hello, ' + name.charAt(0).toUpperCase() + name.slice(1);
}
ch. 07

If Statements

Making decisions in code based on conditions

Conditionals branch the execution path based on boolean expressions. Use else if for ladders and default to the general case.

  1. Evaluate boolean expression
  2. If true → run the `if` block
  3. If false → run the `else` block (or nothing)
  4. Continue with next statement
try.it()
javascript
const age = 20;
if (age >= 18) {
  console.log('Eligible to vote');
} else {
  console.log('Come back at 18');
}
ch. 08

Loops

Repeating code execution multiple times

Loops save you from copy-pasting. Three flavours in most languages: for (fixed count), while (condition-first), do-while (condition-after).

For Loop
Fixed iterations
While Loop
Condition-based
Do-While
Execute then check
For…of
Iterate values
try.it()
javascript
for (let i = 0; i < 5; i++) console.log(i);

let n = 3;
while (n > 0) { console.log(n); n--; }
ch. 09

Arrays

Ordered collections of elements under one variable

Arrays are zero-indexed lists. Use them to model sequences: students in a class, tasks in a queue, frames of an animation.

OperationMethodDescription
Add to endpush()Appends to the array
Remove from endpop()Removes and returns last
Add to startunshift()Prepends
Remove from startshift()Removes and returns first
Length.lengthNumber of elements
try.it()
javascript
const fruits = ['apple', 'banana', 'orange'];
fruits.push('mango');
for (const f of fruits) console.log(f);
ch. 10

Strings

Sequences of characters used to represent text

Strings are immutable in most languages. Use template literals for interpolation, and built-in methods for trimming, splitting, replacing, and searching.

.length
Character count
.toUpperCase()
UPPER
.split(',')
Array of parts
.replace(a,b)
Substitute
try.it()
javascript
const name = 'Codekilla';
console.log(`Hello, ${name}!`);
console.log(name.toUpperCase());  // CODEKILLA
ch. 11

Functions

Reusable blocks of code that perform specific tasks

A function encapsulates logic. Call it by name, pass arguments, get a return value. Small, focused functions (under 30 lines) are the hallmark of maintainable code.

  1. Function Call — invoke with arguments
  2. Parameter Binding — arguments map to parameters
  3. Execute Body — run function code
  4. Return Value — send result back
try.it()
javascript
function add(a, b) {
  return a + b;
}

const arrow = (x) => x * x;
console.log(add(3, 4), arrow(5)); // 7 25
ch. 12

Recursion

Functions that call themselves to solve problems

A recursive function solves a big problem by solving smaller versions of the same problem. Always include a base case — otherwise you stack-overflow.

try.it()
javascript
function factorial(n) {
  if (n <= 1) return 1;    // base case
  return n * factorial(n - 1);
}
console.log(factorial(5)); // 120
ch. 13

Scope

The accessibility and visibility of variables

Global scope is accessible everywhere. Function scope is local to a function. Block scope ({ }) applies to let/const inside braces.

Global
Everywhere
Function
Within a function
Block
Within { }
Module
Within a file / module
try.it()
javascript
const global_x = 1;
function f() {
  const local_y = 2;
  if (true) {
    const block_z = 3;
    console.log(global_x, local_y, block_z);
  }
  // block_z is not accessible here
}
ch. 14

Type Casting

Converting values from one data type to another

Implicit coercion happens automatically (e.g. '5' + 1 → '51'). Explicit casting is safer — you declare intent.

String → Number
Number('42')
Number → String
String(42)
Any → Boolean
Boolean(0) // false
parseInt / parseFloat
parseInt('10px') // 10
try.it()
javascript
console.log(Number('42') + 1);  // 43
console.log(String(42) + 1);    // '421'
console.log(Boolean(''));       // false
ch. 15

Bits & Bytes

The fundamental units of digital information

A bit is a single 0 or 1. Eight bits make a byte. Memory and storage are measured in bytes and their multiples.

UnitSizeExample
Bit1 bit0 or 1
Nibble4 bits1011
Byte8 bits10110101
Kilobyte (KB)1024 bytesSmall text file
Megabyte (MB)1024 KBHigh-res image
Gigabyte (GB)1024 MBHD movie
try.it()
javascript
const byte = 0b10110101; // 181
console.log(byte.toString(2)); // '10110101'
ch. 16

Number Systems

Binary, Octal, Decimal, Hexadecimal

A number system is a way of representing numbers using a set of symbols. The base (radix) determines how many unique digits are available.

DecimalBinaryOctalHex
0000000
5010155
10101012A
15111117F
16100002010
25511111111377FF
try.it()
javascript
// Different base literals in JS
const bin = 0b1010;  // 10
const oct = 0o12;    // 10
const hex = 0xA;     // 10
console.log(bin, oct, hex); // 10 10 10
ch. 17

Boolean Algebra

Logic operations with true / false values

Three fundamental operators — AND, OR, NOT — let you combine booleans. They're the foundation of every conditional you'll ever write.

ABA && BA || B
falsefalsefalsefalse
falsetruefalsetrue
truefalsefalsetrue
truetruetruetrue
try.it()
javascript
console.log(true && false); // false
console.log(true || false); // true
console.log(!true);         // false
ch. 18

Input & Output

Getting data from users and displaying results

Every program follows Input → Process → Output. Input can come from keyboards, files, APIs. Output goes to the console, DOM, files, or network responses.

  1. Input — receive data (keyboard, mouse, file, network)
  2. Validation — check the input is safe & valid
  3. Processing — transform the data
  4. Output — deliver the result to the right destination
try.it()
javascript
const name = prompt('Your name?');
const upper = (name || 'friend').toUpperCase();
console.log(`Hello, ${upper}!`);