Coding Challenges
Solve 83+ interactive puzzles — predict outputs, hunt bugs, complete code & reorder logic across 6 languages.
0
Total XP
Lv 1
Level
0
Day Streak
0/83
Solved
Language
Type
Difficulty
Status
83 challenges available
String Concatenation
What does this code print?
console.log("Hello" + " " + "World");Type Coercion
What is the output?
console.log(5 + "3");Array Destructuring
What gets logged?
const [a, , b] = [1, 2, 3, 4];
console.log(a, b);Spread Operator
What is the result?
const a = [1, 2];
const b = [0, ...a, 3];
console.log(b.length);Closure Trap
What does this log?
for (var i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 0);
}
// Output after all…Off-by-One Error
This function should return the last element of an array, but it has a bug.
function lastElement(arr) {
return arr[arr.length];
}Equality Check Bug
This comparison always returns false even for matching values.
function isEqual(a, b) {
if (a = b) {
return true;
}
return false;
}Async Await Missing
This function should wait for data but returns a Promise instead.
async function getData(url) {
const response = fetch(url);
const data = response.json(…Arrow Function
Complete the arrow function that doubles a number.
const double = (n) ___ n * 2;Array Method Chain
Complete the chain to get names of adults.
const adults = people
.filter(p => p.age >= 18)
.___((p) => p.name);Promise.all Pattern
Complete the code to fetch multiple URLs concurrently.
const results = await Promise.___([
fetch("/api/users"),
fetch("/api/posts"),
fetch(…Function Declaration
Arrange these lines to create a working function.
return a + b;
function add(a, b) {
}Fetch API Pattern
Reorder to make a proper fetch call.
const data = await response.json();
const response = await fetch(url);
return data;
async …Event Listener Setup
Reorder to properly set up a click counter.
button.addEventListener("click", handleClick);
let count = 0;
const button = document.getE…List Slicing
What does this print?
nums = [10, 20, 30, 40, 50]
print(nums[1:3])String Multiply
What is the output?
print("ab" * 3)Dictionary Comprehension
What does this produce?
result = {x: x**2 for x in range(4)}
print(result)Unpacking Values
What gets printed?
a, *b, c = [1, 2, 3, 4, 5]
print(b)Mutable Default Argument
What happens when we call this twice?
def add_item(item, lst=[]):
lst.append(item)
return lst
print(add_item("a"))
prin…Indentation Error
This function has a bug preventing it from running.
def greet(name):
return f"Hello, {name}"Integer Division Bug
This should return a float average but returns an integer.
def average(numbers):
total = sum(numbers)
return total // len(numbers)Scope Error in Loop
This should create 3 functions that print 0, 1, 2 but all print 2.
functions = []
for i in range(3):
functions.append(lambda: print(i))
for f in functio…List Comprehension
Complete the list comprehension for squares.
squares = [x**2 ___ x in range(5)]Exception Handling
Complete the error handling pattern.
try:
result = 10 / 0
___ ZeroDivisionError:
print("Cannot divide by zero")Decorator Syntax
Complete the decorator pattern.
def timer(func):
def wrapper(*args, **kwargs):
start = time.time()
res…Class Definition
Arrange to create a proper Python class.
self.name = name
def __init__(self, name):
class Dog:
return f"{self.name} says Wo…File Reading Pattern
Reorder to read a file properly.
for line in file:
with open("data.txt", "r") as file:
print(line.strip())String Comparison
What does this print?
String a = "hello";
String b = "hello";
System.out.println(a == b);Array Length
What is the output?
int[] arr = {10, 20, 30};
System.out.println(arr.length);Integer Caching
What does this comparison return?
Integer a = 127;
Integer b = 127;
Integer c = 128;
Integer d = 128;
System.out.println(a =…Missing Semicolon
This code won't compile. Find the fix.
int sum = 0;
for (int i = 0; i < 10; i++) {
sum += i
}
System.out.println(sum);String Equality Bug
This always returns false for matching strings.
public boolean isMatch(String input) {
String target = new String("hello");
return…Main Method Signature
Complete the Java main method.
public static void ___(String[] args) {
System.out.println("Hello!");
}Enhanced For Loop
Complete the enhanced for loop.
List<String> names = Arrays.asList("Alice", "Bob");
___ (String name : names) {
System…Simple Class
Arrange to create a valid Java class.
}
public void greet() {
public class Person {
System.out.println("Hello!")…Vector Size
What does this output?
vector<int> v = {1, 2, 3, 4};
cout << v.size();Reference vs Copy
What is the output?
int a = 5;
int& b = a;
b = 10;
cout << a;Pointer Arithmetic
What is printed?
int arr[] = {10, 20, 30, 40};
int* ptr = arr;
ptr += 2;
cout << *ptr;Missing Include
This code won't compile. What's missing?
int main() {
cout << "Hello" << endl;
return 0;
}Auto Keyword
Complete using the auto keyword.
___ result = 3.14 * 2;Range-Based For
Complete the range-based for loop.
vector<int> nums = {1, 2, 3};
for (int n ___ nums) {
cout << n << " ";
}Type Assertion
What does this output?
const value: any = "hello";
const len = (value as string).length;
console.log(len);Optional Chaining
What is the output?
const user = { name: "Alice", address: undefined };
console.log(user.address?.city ?? "Unk…Enum Values
What does this output?
enum Color { Red, Green, Blue }
console.log(Color.Green);
console.log(Color[1]);Missing Type Annotation
This function has a type error.
function add(a, b) {
return a + b;
}Interface Definition
Complete the interface.
___ User {
name: string;
age: number;
}Generic Function
Complete the generic function.
function identity<___>(arg: T): T {
return arg;
}Type Guard Pattern
Arrange to create a proper type guard.
return typeof value === "string";
function isString(value: unknown): value is string {…COUNT Function
What does this query return?
SELECT COUNT(*) FROM employees
WHERE department = 'Sales';NULL Comparison
How many rows does this return if 3 users have NULL email?
SELECT * FROM users WHERE email = NULL;GROUP BY with HAVING
What does this query do?
SELECT department, AVG(salary) AS avg_sal
FROM employees
GROUP BY department
HAVING AVG(sa…Wrong Wildcard
This LIKE query finds no matches.
SELECT * FROM products
WHERE name LIKE 'Phone*';JOIN Clause
Complete the JOIN query.
SELECT users.name, orders.total
FROM users
___ JOIN orders ON users.id = orders.user_id;Subquery Pattern
Complete the subquery.
SELECT name FROM employees
WHERE salary > (
SELECT ___(salary) FROM employees
);Complete SELECT Query
Arrange the SQL clauses in correct order.
ORDER BY total DESC
SELECT customer, SUM(amount) AS total
HAVING SUM(amount) > 100
GROUP B…Boolean Conversion
What is the output?
console.log(Boolean(""));
console.log(Boolean("0"));Object Keys
What does this log?
const obj = { 1: "a", 2: "b", 3: "c" };
console.log(Object.keys(obj));Promise.race
What gets logged?
const p1 = new Promise(r => setTimeout(() => r("slow"), 200));
const p2 = new Promise(r =>…String Methods
What is the output?
text = "hello world"
print(text.title())Zip Function
What does this produce?
names = ["Alice", "Bob"]
ages = [25, 30]
print(list(zip(names, ages)))Const Assertion
What is the type of colors?
const colors = ["red", "blue"] as const;
// What is typeof colors?Null Check Missing
This crashes when user is null.
function getNameLength(user: { name: string } | null) {
return user.name.length;
}Ternary Operator
What does this print?
int x = 7;
String result = (x > 5) ? "big" : "small";
System.out.println(result);StringBuilder
What is the output?
StringBuilder sb = new StringBuilder("Hello");
sb.append(" World").reverse();
System.out.p…String Length
What does this output?
string s = "Hello";
cout << s.length();Map Insertion
What is printed?
map<string, int> m;
m["a"] = 1;
m["b"] = 2;
m["a"] = 3;
cout << m["a"] << " " << m.size();DISTINCT Keyword
What does DISTINCT do?
SELECT DISTINCT department
FROM employees;GROUP BY Error
This query fails. What's wrong?
SELECT department, name, COUNT(*)
FROM employees
GROUP BY department;Template Literals
What is the output?
const name = "World";
console.log(`Hello ${name}!`);NaN Comparison
What does this log?
console.log(NaN === NaN);
console.log(typeof NaN);Generator Expression
What is the output?
gen = (x**2 for x in range(3))
print(next(gen))
print(next(gen))F-String Format
Complete the f-string.
name = "Alice"
age = 30
print(___"My name is {name} and I am {age}")Stream API
Complete the stream operation.
List<Integer> nums = Arrays.asList(1, 2, 3, 4, 5);
int sum = nums.stream()
.filter(n -…Dangling Reference
This function returns a dangerous reference.
int& getRef() {
int x = 42;
return x;
}Window Function
Complete the window function.
SELECT name, salary,
RANK() ___ (ORDER BY salary DESC) AS rank
FROM employees;Mapped Type
Complete the mapped type.
type Readonly<T> = {
___[P in keyof T]: T[P];
};Const Reassignment
This code throws an error.
const count = 0;
count = count + 1;
console.log(count);Wrong Comparison
This always returns True for None checks.
def is_valid(value):
if value == None:
return False
return TrueConcurrentModificationException
This crashes when removing items while iterating.
List<String> items = new ArrayList<>(Arrays.asList("a", "b", "c"));
for (String item : ite…Context Manager
Arrange the custom context manager.
yield self.resource
class ManagedResource:
def __enter__(self):
def __exit…Class with Constructor
Arrange the C++ class properly.
public:
int getArea() { return width * height; }
class Rectangle {
private:
int wi…Generic Class
Arrange the generic stack class.
pop(): T | undefined { return this.items.pop(); }
push(item: T): void { this.items…Complex Query
Arrange this analytics query.
GROUP BY c.name
SELECT c.name, COUNT(o.id) AS total_orders, SUM(o.amount) AS revenue
HAVIN…Sharpen Your Coding Skills
83+ interactive challenges across 6 languages. Earn XP, track your streak, and master every concept.