ForgewellCertification Platform
Course dashboard
Preview Module 1

Programming Foundations

Variables, data types, conditionals, loops, functions, and disciplined problem solving.

Outcome

Trace code by hand, choose the right control flow, write small pure functions, and handle edge cases before coding.

Case prompt

Build a small certification-score calculator from plain JavaScript logic.

12 min

How Programs Think

Lesson

Understand code as a sequence of precise instructions operating on values.

Core concepts

  • - Mental model
  • - Professional habit

Example

Programs are not smart; they are literal. The developer's job is to convert a messy human goal into small instructions that a computer can follow without guessing. Before writing code, identify the inputs, transformation, and expected output. This keeps beginner work from becoming trial-and-error typing. A developer who can explain the data flow can usually debug the implementation.

Code block

const passingScore = 80; const learnerScore = 86; const passed = learnerScore >= passingScore;

Practice assignment

Trace three lines of code and write the value of every variable after each line.

Expected deliverable

A one-page trace table for a simple scoring program.

Mistakes to avoid

  • - Jumping into syntax before defining the inputs and expected output
  • - Treating the computer as if it can infer intent
  • - Skipping a hand-trace for a confusing snippet

14 min

Variables, Constants, and Naming

Lesson

Use names that make business rules and program state readable.

Core concepts

  • - Readable names
  • - Constants vs changing state

Example

A variable name should answer what the value means in the domain, not only what type it is. `score` is better than `num`; `passingScore` is better than `x`. Use `const` by default when a binding should not be reassigned. Use `let` only when the value is intentionally updated, such as a running total.

Code block

const completedLessons = 12; const requiredLessons = 40; const isCourseComplete = completedLessons >= requiredLessons;

Practice assignment

Rename five vague variables into names that reveal intent.

Expected deliverable

A cleaned-up variable naming exercise.

Mistakes to avoid

  • - Single-letter names outside trivial loops
  • - Reusing the same variable for unrelated values
  • - Reaching for `var` instead of `const`/`let`

13 min

Data Types and Conversion

Lesson

Recognize strings, numbers, booleans, arrays, objects, null, and undefined.

Core concepts

  • - Core types
  • - Missing values

Example

Most beginner bugs come from treating one type as another. Form input arrives as text, API fields may be missing, and arithmetic requires real numbers. `undefined` usually means a value was never provided. `null` usually means the absence was intentional. In production code, both deserve deliberate handling.

Code block

Number('42') + 8 // 50 '42' + 8 // '428' Boolean('false') // true

Practice assignment

Classify sample values and predict conversion results.

Expected deliverable

A type-classification worksheet.

Mistakes to avoid

  • - Adding a string and a number expecting arithmetic
  • - Treating non-empty strings like 'false' as falsy
  • - Conflating undefined with null without checking origins

14 min

Conditionals and Business Rules

Lesson

Turn requirements into explicit branches and guard clauses.

Core concepts

  • - Branching
  • - Edge cases

Example

A conditional should read like the rule it represents. Keep each condition focused and avoid nesting when a guard clause can exit early. Ask what happens at the boundary: exactly 80, exactly 0, missing score, negative score, and scores above 100.

Code block

function getCertificateStatus(score) { if (score < 0 || score > 100) return 'invalid'; if (score >= 80) return 'passed'; return 'review-required'; }

Practice assignment

Write conditions for pass/fail, discount eligibility, and incomplete profile states.

Expected deliverable

A set of tested conditional rules in pseudocode.

Mistakes to avoid

  • - Forgetting a boundary case (e.g. exactly the passing score)
  • - Deeply nesting branches instead of using guard clauses
  • - Letting one condition implicitly cover invalid input

13 min

Loops and Repetition

Lesson

Use loops to repeat work while keeping the stop condition obvious.

Core concepts

  • - Loop anatomy
  • - Choosing the loop

Example

Every loop needs a collection or range, a body of work, and a way to finish. Infinite loops often come from unclear stopping conditions. `for...of` is readable for arrays. Use array methods later when transformation intent is clearer than manual control.

Code block

let total = 0; for (const score of scores) { total += score; }

Practice assignment

Sum an array of quiz scores and count how many are passing.

Expected deliverable

A simple loop-based score summary.

Mistakes to avoid

  • - Forgetting to advance the index in a manual `for` loop
  • - Mutating the array you are iterating over
  • - Choosing a verbose loop when `map`/`filter`/`reduce` would be clearer

14 min

Functions and Problem Solving

Lesson

Build small functions that can be tested with sample inputs.

Core concepts

  • - Function contracts
  • - Problem-solving sequence

Example

A function contract is the promise between caller and implementation: inputs, output, and behavior for edge cases. Restate the goal, write examples, identify edge cases, choose the data structure, then code. This is the workflow expected in the rest of the certification.

Code block

function average(scores) { if (scores.length === 0) return 0; return scores.reduce((sum, score) => sum + score, 0) / scores.length; }

Practice assignment

Write examples first, then implement a function from those examples.

Expected deliverable

A pure function with three sample cases.

Mistakes to avoid

  • - Returning undefined for an edge case instead of a documented value
  • - Mixing IO and logic so the function can't be tested
  • - Skipping the example list before implementing

Chapter quiz

Programming Foundations quiz

Sign in to save your attempts to your account and continue from any device.

Question 1

Programming fundamentals / multiple-choice

1. Which value is best represented as a boolean?

Question 2

Programming fundamentals / multiple-choice

2. What does this function return for a score of 80?

function getStatus(score) {
  if (score >= 80) return 'passed';
  return 'review-required';
}
Question 3

Programming fundamentals / multiple-choice

3. Why write sample inputs and outputs before coding?

Question 4

Programming fundamentals / multiple-choice

4. Which issue is most likely in this snippet?

const lessonCount = '10';
const total = lessonCount + 5;
Question 5

Programming fundamentals / multiple-choice

5. What should a function do when it receives invalid input?