JavaScript challenges
Practice problem statements with input format, output format, constraints and solutions.
JS Introduction challenge
Build a small solution that uses JS Introduction in JavaScript and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
const lesson = "JS Introduction";
const checklist = ["understand", "run", "change", "explain"];
console.log(lesson + ": " + checklist.join(" -> "));Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core js introduction pattern before polishing the final output.
Solution
const lesson = "JS Introduction solution";
const checklist = ["understand", "run", "change", "explain"];
console.log(lesson + ": " + checklist.join(" -> "));Variables challenge
Build a small solution that uses Variables in JavaScript and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
const lesson = "Variables";
const checklist = ["understand", "run", "change", "explain"];
console.log(lesson + ": " + checklist.join(" -> "));Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core variables pattern before polishing the final output.
Solution
const lesson = "Variables solution";
const checklist = ["understand", "run", "change", "explain"];
console.log(lesson + ": " + checklist.join(" -> "));Data Types challenge
Build a small solution that uses Data Types in JavaScript and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
const lesson = "Data Types";
const checklist = ["understand", "run", "change", "explain"];
console.log(lesson + ": " + checklist.join(" -> "));Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core data types pattern before polishing the final output.
Solution
const lesson = "Data Types solution";
const checklist = ["understand", "run", "change", "explain"];
console.log(lesson + ": " + checklist.join(" -> "));Operators challenge
Build a small solution that uses Operators in JavaScript and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
const lesson = "Operators";
const checklist = ["understand", "run", "change", "explain"];
console.log(lesson + ": " + checklist.join(" -> "));Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core operators pattern before polishing the final output.
Solution
const lesson = "Operators solution";
const checklist = ["understand", "run", "change", "explain"];
console.log(lesson + ": " + checklist.join(" -> "));Conditions challenge
Build a small solution that uses Conditions in JavaScript and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
const lesson = "Conditions";
const checklist = ["understand", "run", "change", "explain"];
console.log(lesson + ": " + checklist.join(" -> "));Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core conditions pattern before polishing the final output.
Solution
const lesson = "Conditions solution";
const checklist = ["understand", "run", "change", "explain"];
console.log(lesson + ": " + checklist.join(" -> "));Loops challenge
Build a small solution that uses Loops in JavaScript and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
const lesson = "Loops";
const checklist = ["understand", "run", "change", "explain"];
console.log(lesson + ": " + checklist.join(" -> "));Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core loops pattern before polishing the final output.
Solution
const lesson = "Loops solution";
const checklist = ["understand", "run", "change", "explain"];
console.log(lesson + ": " + checklist.join(" -> "));Functions challenge
Build a small solution that uses Functions in JavaScript and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
const lesson = "Functions";
const checklist = ["understand", "run", "change", "explain"];
console.log(lesson + ": " + checklist.join(" -> "));Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core functions pattern before polishing the final output.
Solution
const lesson = "Functions solution";
const checklist = ["understand", "run", "change", "explain"];
console.log(lesson + ": " + checklist.join(" -> "));Arrays challenge
Build a small solution that uses Arrays in JavaScript and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
const orders = [42, 120, 18, 75]; const largeOrders = orders.filter((total) => total >= 57); console.log(largeOrders);
Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core arrays pattern before polishing the final output.
Solution
const orders = [42, 120, 18, 75]; const largeOrders = orders.filter((total) => total >= 57); console.log(largeOrders);
Objects challenge
Build a small solution that uses Objects in JavaScript and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
const customer = { name: "Asha", plan: "Pro", active: true };
console.log(customer.name + " uses " + customer.plan);Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core objects pattern before polishing the final output.
Solution
const customer = { name: "Asha", plan: "Pro", active: true };
console.log(customer.name + " uses " + customer.plan);Strings challenge
Build a small solution that uses Strings in JavaScript and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
const lesson = "Strings";
const checklist = ["understand", "run", "change", "explain"];
console.log(lesson + ": " + checklist.join(" -> "));Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core strings pattern before polishing the final output.
Solution
const lesson = "Strings solution";
const checklist = ["understand", "run", "change", "explain"];
console.log(lesson + ": " + checklist.join(" -> "));