Skip to content

aniketsinha-dev/javascript-practice-questions

 
 

Repository files navigation

🚀 JavaScript Practice Questions

Master JS fundamentals before you touch DSA or LeetCode

Questions Difficulty Language PRs Welcome Stars


Do these before LeetCode. Do these before DSA. If you can't swap two numbers or reverse a string confidently — you're not ready for linked lists yet. Start here.


👋 Why does this repo exist?

Every year, thousands of students learn JavaScript — watch tutorials, follow along with courses — and then open LeetCode or start a DSA playlist and immediately feel lost.

Not because they're not smart. But because they skipped the fundamentals.

Before you worry about Linked Lists, Binary Trees, or Dynamic Programming — you need to be genuinely comfortable with:

  • loops, conditions, and functions
  • how strings and arrays actually work
  • writing logic from scratch, not just reading it

This repo is that missing middle step. 276 questions, written in LeetCode style, covering pure JavaScript fundamentals. No frameworks, no setup — just you and the language.

💡 Think of this as your "pre-DSA checklist" — if you can solve these confidently, you're ready for the harder stuff.


📚 What's Inside

# Topic Questions File
1 🔤 Variables & Data Types Q1 – Q10 01-variables-and-data-types.md
2 ➕ Operators Q11 – Q20 02-operators.md
3 🔀 if / if-else Q21 – Q35 03-if-and-if-else.md
4 🪜 if-else-if Ladder Q36 – Q45 04-if-else-if-ladder.md
5 🔁 switch Statement Q46 – Q55 05-switch-statement.md
6 🔄 for Loop Q56 – Q80 06-for-loop.md
7 ⏳ while & do-while Loop Q81 – Q101 07-while-and-do-while.md
8 ⛔ break & continue Q102 – Q121 08-break-and-continue.md
9 🔲 Nested Loops & Patterns Q122 – Q136 09-nested-loops-patterns.md
10 🧩 Functions Q137 – Q156 10-functions.md
11 🔡 Strings Q157 – Q181 11-strings.md
12 📦 Arrays Q182 – Q211 12-arrays.md
13 🛠️ Array Methods Q212 – Q237 13-array-methods.md
14 🗂️ Objects, Set, Map & Recursion Q238 – Q276 14-objects-set-map-recursion.md

🎯 Difficulty Breakdown

🟢 Easy      ████████████████████░░░  ~220 questions
🟡 Medium    ████░░░░░░░░░░░░░░░░░░░   ~45 questions
🔴 Hard      █░░░░░░░░░░░░░░░░░░░░░░   ~11 questions

Hard problems are kept minimal — the goal is to build a rock-solid foundation, not to overwhelm you.


🗺️ Suggested Learning Path

Follow this order — each topic builds on the previous one:

Variables & Data Types
      ↓
  Operators
      ↓
if / if-else / switch
      ↓
Loops (for → while → do-while)
      ↓
break / continue / Nested Loops & Patterns
      ↓
Functions
      ↓
Strings
      ↓
Arrays → Array Methods
      ↓
Objects → Set → Map
      ↓
Recursion  ← once you're here, you're ready for DSA 🎉

Once you finish this list, you'll have the mental model to tackle Data Structures and Algorithms with confidence. Loops and strings alone will make up 60% of your early DSA problems — master them here first.


🍴 How to Use This Repo

Simple rule: start from Q1 and go in order. Each section builds on the previous one — don't skip around.

🆕 New to git? Use Option 1 for now — come back to Option 2 once you're comfortable.


Option 1 — Just Browse on GitHub

Read any .md file directly on GitHub. No setup needed. Pick a question, open your editor or an online platform, and solve it.

To run your code — use VS Code, your browser console (F12), or any online JavaScript runner you prefer.


Option 2 — Clone & Solve in VS Code (Recommended ⭐)

Step 1: Fork this repo

Click the Fork button at the top-right of this page. This creates your own personal copy on your GitHub.

Step 2: Clone your fork

git clone https://github.com/aman-sinha-dev/javascript-practice-questions.git
cd javascript-practice-questions

Step 3: Create your solutions/ folder

This is your personal workspace — organize it however you like:

javascript-practice-questions/
├── solutions/                  ← create this folder
│   ├── 01-variables.js
│   ├── 02-operators.js
│   ├── 06-for-loop.js
│   └── ...
├── 01-variables-and-data-types.md   ← read questions here
├── 02-operators.md
└── ...

Step 4: Open in VS Code and start from Q1

code .

Open 01-variables-and-data-types.md, read Q1, create solutions/01-variables.js, and write your answer. Then move to Q2. Simple as that.

Step 5: Save your progress with git

git add solutions/
git commit -m "solved: Q1-Q10 variables section"
git push origin main

💡 Tips for Beginners

  • Don't rush. Doing 3 questions well beats doing 10 questions poorly.
  • Try without hints first. Even if you're stuck for 20 minutes — that struggle builds the skill.
  • Write it out, don't copy. Typing code yourself is how it actually sticks.
  • Google is allowed. Knowing how to search is also a skill. Just don't paste solutions blindly.
  • Revisit questions. Come back to problems you found hard — you'll be surprised how easy they feel later.

🤝 Contributing

Found a typo? Want to add a better example? Have a cleaner way to phrase a question?

PRs are welcome!

# 1. Fork the repo (click Fork on GitHub)
# 2. Clone your fork
git clone https://github.com/aman-sinha-dev/javascript-practice-questions.git

# 3. Create a branch
git checkout -b fix/question-47-typo

# 4. Make your changes

# 5. Push and open a PR
git push origin fix/question-47-typo

Please do not add solution files to the main question files — keep questions and solutions separate.


⭐ Show Some Love

If this helped you, consider giving the repo a star ⭐ — it helps other students find it too.


The best time to build fundamentals is before you need them.

Practice here. Then go conquer DSA. 💪


Made with ❤️ by Aman Sinha — for every student who felt lost before finding this.

About

276 LeetCode-style JavaScript questions for beginners. Practice JS fundamentals before diving into DSA.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors