Programming Basics
150 exercises
Practice exercises for programming fundamentals.
- 1
Variable Declaration Quiz
Test your understanding of variable declaration keywords in modern JavaScript.
Multiple Choice Beginner - 2
Declare a Constant Practice
Practice using the correct keyword to declare a constant variable.
Fill in the Blank Beginner - 3
Identify the Data Type
Practice recognizing common data types used in programming languages.
Multiple Choice Beginner - 4
Predict the typeof Output
Predict what the JavaScript typeof operator returns for a string value.
Predict Output Easy - 5
Understanding Functions
Check your conceptual understanding of what a function is in programming.
Concept Check Beginner - 6
Spot the Function Syntax Error
Find and fix a common syntax error in a JavaScript function declaration.
Find the Mistake Easy - 7
Equality Operator Quiz
Test your understanding of the equality comparison operator used in most programming languages.
Multiple Choice Beginner - 8
Predict the if/else Output
Predict which branch of an if/else statement runs based on a condition.
Predict Output Beginner - 9
Predict the for Loop Output
Predict the final value of a counter after a for loop completes.
Predict Output Beginner - 10
Spot the Loop Mistake
Find a common off-by-one error in a for loop that should print three times.
Find the Mistake Easy - 11
Array Indexing Quiz
Test your understanding of how array indexing works (zero-based).
Multiple Choice Beginner - 12
Predict Array Access
Predict the value returned by accessing an array element by index.
Predict Output Beginner - 13
Object Property Access Quiz
Test your understanding of how to access a property on an object using dot notation.
Multiple Choice Beginner - 14
What Is an Object?
Check your conceptual understanding of what an object is in programming.
Concept Check Beginner - 15
let vs const Reassignment
Test whether you understand which keyword allows reassignment.
Multiple Choice Beginner - 16
Predict Variable Swap Output
Predict the output after swapping two variables using a temp variable.
Predict Output Easy - 17
Declare a Mutable Variable
Practice using the correct keyword for a variable that will change.
Fill in the Blank Beginner - 18
Why Use Variables?
Check your conceptual understanding of why variables are useful.
Concept Check Beginner - 19
Spot the Variable Mistake
Find a common mistake when using variables in JavaScript.
Find the Mistake Easy - 20
Variable Naming Rules
Test your knowledge of valid variable naming conventions.
Multiple Choice Beginner - 21
String vs Number Quiz
Distinguish between string and number values in code.
Multiple Choice Beginner - 22
Predict typeof for null
Predict what typeof returns for null in JavaScript (a known quirk).
Predict Output Medium - 23
Convert String to Number
Practice converting a string to a number using a built-in function.
Fill in the Blank Easy - 24
Why Types Matter
Check your understanding of why data types are important.
Concept Check Beginner - 25
Spot the Type Coercion Bug
Find a bug caused by unexpected type coercion.
Find the Mistake Medium - 26
Boolean Value Quiz
Test your understanding of boolean values.
Multiple Choice Beginner - 27
Strict vs Loose Equality
Test your understanding of === vs == in JavaScript.
Multiple Choice Medium - 28
Predict Nested if Output
Predict the output of nested conditional statements.
Predict Output Medium - 29
Complete the if Statement
Fill in the correct comparison operator for a range check.
Fill in the Blank Beginner - 30
Understanding else if
Check your conceptual understanding of else if chains.
Concept Check Beginner - 31
Spot the Assignment vs Comparison Bug
Find a common bug where assignment is used instead of comparison.
Find the Mistake Medium - 32
Logical AND Operator
Test your understanding of the && (AND) operator.
Multiple Choice Easy - 33
for Loop Iteration Count
Calculate how many times a for loop runs.
Multiple Choice Easy - 34
Predict while Loop Output
Predict the output of a while loop with a countdown.
Predict Output Easy - 35
Complete the for Loop
Fill in the loop condition to iterate over an array.
Fill in the Blank Easy - 36
for vs while Choice
Check your understanding of when to use for vs while loops.
Concept Check Easy - 37
Spot the Infinite Loop
Find the bug that causes an infinite loop.
Find the Mistake Medium - 38
Predict break Output
Predict the output when a loop uses a break statement.
Predict Output Medium - 39
Function Return Value Quiz
Test your understanding of what a function returns.
Multiple Choice Beginner - 40
Predict Function Call Output
Predict the output of calling a function with arguments.
Predict Output Easy - 41
Complete the Return Statement
Fill in the return statement to make the function work.
Fill in the Blank Beginner - 42
Parameter vs Argument
Distinguish between parameters and arguments.
Concept Check Easy - 43
Spot the Missing Return
Find a bug where a function does not return the expected value.
Find the Mistake Easy - 44
Default Parameter Quiz
Test your understanding of default parameter values.
Multiple Choice Medium - 45
Array Length Quiz
Test your understanding of array length property.
Multiple Choice Beginner - 46
Predict Array push Output
Predict the array after using the push method.
Predict Output Easy - 47
Access the Last Element
Fill in the code to access the last element of an array.
Fill in the Blank Easy - 48
Array vs Object Choice
Check your understanding of when to use an array vs an object.
Concept Check Easy - 49
Spot the Array Index Bug
Find an off-by-one error when accessing array elements.
Find the Mistake Easy - 50
Predict Array map Output
Predict the output of the array map method.
Predict Output Medium - 51
Object Property Quiz
Test your understanding of adding properties to objects.
Multiple Choice Easy - 52
Predict Object Access Output
Predict the output when accessing object properties.
Predict Output Easy - 53
Add a Property to an Object
Fill in the code to add a new property to an existing object.
Fill in the Blank Easy - 54
Object Keys Quiz
Check your understanding of what object keys are.
Concept Check Easy - 55
Spot the Object Access Bug
Find a bug when accessing a non-existent property.
Find the Mistake Easy - 56
Nested Object Access
Test your understanding of accessing properties in nested objects.
Multiple Choice Medium - 57
String Concatenation Quiz
Test your understanding of joining strings together.
Multiple Choice Beginner - 58
Predict String Length
Predict the length of a string including spaces.
Predict Output Easy - 59
Convert String to Uppercase
Fill in the method to convert a string to uppercase.
Fill in the Blank Easy - 60
String Immutability
Check your understanding of string immutability.
Concept Check Medium - 61
Spot the String Index Bug
Find a bug when using string methods.
Find the Mistake Easy - 62
Predict String slice Output
Predict the output of the string slice method.
Predict Output Medium - 63
Modulo Operator Quiz
Test your understanding of the modulo (remainder) operator.
Multiple Choice Easy - 64
Predict Integer Division
Predict the result of division in JavaScript.
Predict Output Easy - 65
Round a Number
Fill in the method to round a number to the nearest integer.
Fill in the Blank Easy - 66
Floating Point Precision
Check your understanding of floating-point arithmetic limitations.
Concept Check Medium - 67
Spot the Math Operation Bug
Find a bug in a mathematical calculation.
Find the Mistake Medium - 68
Power Operator Quiz
Test your understanding of exponentiation in JavaScript.
Multiple Choice Easy - 69
Logical OR Operator Quiz
Test your understanding of the || (OR) operator.
Multiple Choice Easy - 70
Predict NOT Operator Output
Predict the output of the logical NOT operator.
Predict Output Easy - 71
Combine Conditions with AND
Fill in the logical operator to require both conditions.
Fill in the Blank Easy - 72
Truthiness Concept
Check your understanding of truthy and falsy values.
Concept Check Medium - 73
Spot the De Morgan's Law Bug
Find a logic error when negating compound conditions.
Find the Mistake Medium - 74
Short-Circuit Evaluation
Test your understanding of short-circuit evaluation.
Multiple Choice Medium - 75
Local vs Global Scope Quiz
Test your understanding of variable scope.
Multiple Choice Easy - 76
Predict Scope Shadow Output
Predict the output when a local variable shadows a global one.
Predict Output Medium - 77
Block Scope with let
Fill in the keyword that creates block-scoped variables.
Fill in the Blank Easy - 78
Why Scope Matters
Check your conceptual understanding of why scope is important.
Concept Check Easy - 79
Spot the Scope Bug
Find a bug caused by accessing a variable outside its scope.
Find the Mistake Easy - 80
Base Case Quiz
Test your understanding of the base case in recursion.
Multiple Choice Medium - 81
Predict Factorial Output
Predict the output of a recursive factorial function.
Predict Output Medium - 82
Complete the Recursive Call
Fill in the recursive call for a countdown function.
Fill in the Blank Medium - 83
Recursion vs Iteration
Check your understanding of when recursion is preferable.
Concept Check Medium - 84
Spot the Missing Base Case
Find a bug where a recursive function has no base case.
Find the Mistake Medium - 85
What Is Programming?
Test your understanding of what programming fundamentally is.
Multiple Choice Beginner - 86
Source Code vs Machine Code
Check your understanding of source code and machine code.
Concept Check Beginner - 87
Compilation vs Interpretation
Test your understanding of how code is executed.
Multiple Choice Medium - 88
Predict Execution Order
Predict the order in which statements execute.
Predict Output Easy - 89
Syntax vs Semantics
Check your understanding of syntax vs semantics.
Concept Check Medium - 90
Statement Terminator
Fill in the character that ends a statement in many languages.
Fill in the Blank Beginner - 91
Types of Errors Quiz
Test your understanding of different error types.
Multiple Choice Easy - 92
Logic Error Concept
Check your understanding of what a logic error is.
Concept Check Easy - 93
Predict the Error Type
Predict what type of error this code produces.
Predict Output Medium - 94
Spot the Logic Error
Find a logic error that produces the wrong result.
Find the Mistake Easy - 95
Debugging Strategy Quiz
Test your understanding of effective debugging strategy.
Multiple Choice Easy - 96
console.log for Debugging
Check your understanding of using console.log to debug.
Concept Check Easy - 97
Add a Debug Log
Fill in the debugging statement to inspect a variable.
Fill in the Blank Beginner - 98
Comment Syntax Quiz
Test your knowledge of comment syntax in JavaScript.
Multiple Choice Beginner - 99
Good Comments Concept
Check your understanding of what makes a good comment.
Concept Check Easy - 100
Write a Multi-line Comment
Fill in the syntax to start a multi-line comment in JavaScript.
Fill in the Blank Beginner - 101
Const Reassignment Behavior
Understand what happens when reassigning a const variable.
Multiple Choice Beginner - 102
Typeof Null Result
Check the quirky result of typeof null in JavaScript.
Multiple Choice Beginner - 103
Strict vs Loose Equality
Distinguish === from == in JavaScript.
Multiple Choice Beginner - 104
Modulo Operator Result
Predict the result of a modulo expression.
Multiple Choice Beginner - 105
Array Length Property
Determine the length of an array after push.
Multiple Choice Beginner - 106
Object Property Access
Compare dot vs bracket notation for object access.
Multiple Choice Easy - 107
Default Parameter Value
Understand default function parameters in ES6.
Multiple Choice Easy - 108
Var Hoisting Behavior
Understand how var declarations are hoisted.
Multiple Choice Medium - 109
Logical AND Short Circuit
Understand short-circuit evaluation of &&.
Multiple Choice Easy - 110
Logical OR Short Circuit
Understand short-circuit evaluation of ||.
Multiple Choice Easy - 111
Ternary Operator Syntax
Identify valid ternary operator usage.
Multiple Choice Beginner - 112
For Loop Three Parts
Identify the three components of a for loop.
Multiple Choice Beginner - 113
Break vs Continue
Distinguish break from continue in loops.
Multiple Choice Easy - 114
Function Without Return
Understand what a function returns without a return statement.
Multiple Choice Easy - 115
Array Zero Indexing
Remember that arrays start at index 0.
Multiple Choice Beginner - 116
String Immutability
Understand that strings are immutable in JavaScript.
Multiple Choice Easy - 117
NaN Property Check
Understand why NaN is not equal to itself.
Multiple Choice Medium - 118
Infinity Division
Predict the result of dividing by zero.
Multiple Choice Medium - 119
Prefix vs Postfix Increment
Distinguish ++x from x++ in an expression.
Multiple Choice Medium - 120
Type Coercion with String
Predict the result of string + number.
Multiple Choice Medium - 121
Array Spread Operator
Understand the spread operator for arrays.
Multiple Choice Easy - 122
Template Literal Syntax
Identify correct template literal syntax.
Multiple Choice Easy - 123
Falsy Values Check
Identify which values are falsy in JavaScript.
Multiple Choice Medium - 124
Destructuring Assignment
Understand object destructuring syntax.
Multiple Choice Easy - 125
Let Block Scope
Understand that let is block-scoped.
Multiple Choice Medium - 126
Arrow Function This Binding
Understand arrow function this behavior.
Multiple Choice Easy - 127
Exponentiation Operator
Use the ** operator for exponentiation.
Multiple Choice Medium - 128
Switch Fall-Through
Understand switch statement fall-through.
Multiple Choice Easy - 129
Type Coercion with Boolean
Understand how Number() converts booleans.
Multiple Choice Medium - 130
Closure Concept
Identify what a closure captures.
Multiple Choice Medium - 131
Variable Reassignment
Predict output after reassigning a let variable.
Predict Output Beginner - 132
Typeof Multiple Types
Predict typeof for different value types.
Predict Output Beginner - 133
String Concatenation
Predict the result of string concatenation.
Predict Output Beginner - 134
Arithmetic Operations
Predict the result of mixed arithmetic.
Predict Output Beginner - 135
Comparison Chain
Predict the result of comparison operators.
Predict Output Easy - 136
Logical Operator Result
Predict the result of || with truthy values.
Predict Output Easy - 137
Ternary Expression
Predict the result of a ternary expression.
Predict Output Easy - 138
If Else If Chain
Predict which branch runs in an if/else if chain.
Predict Output Easy - 139
For Loop Sum
Predict the sum after a for loop.
Predict Output Easy - 140
While Loop Countdown
Predict the output of a while loop countdown.
Predict Output Medium - 141
Array Push Pop
Predict array state after push and pop.
Predict Output Easy - 142
Array Map Transform
Predict the result of array map.
Predict Output Medium - 143
Array Filter Result
Predict the result of array filter.
Predict Output Medium - 144
Object Property Access
Predict the value of an object property.
Predict Output Easy - 145
Function Call Result
Predict the return value of a function.
Predict Output Easy - 146
Recursive Factorial
Predict the result of a recursive factorial.
Predict Output Medium - 147
Type Coercion in Arithmetic
Predict the result of string subtraction.
Predict Output Medium - 148
String Method Chaining
Predict the result of chained string methods.
Predict Output Easy - 149
Destructuring with Default
Predict destructuring with a default value.
Predict Output Medium - 150
Spread in Function Call
Predict the result of spreading an array into a function.
Predict Output Medium
Build real projects
Apply what you learned by building guided projects with starter code and solutions.