Offline JavaScript Practice Workbook
This PDF helps you learn JavaScript fully offline. Read each question, follow the steps, then
practice in VS Code or [Link].
Section 1: Variables & Data Types
Q1. Create a variable called age and print it.
Steps: Use let, assign a number, print using [Link].
Solution: let age = 22; [Link](age);
Q2. Store your name and whether you are a student.
Solution: let name = "Jennifer"; let isStudent = true;
Section 2: Functions
Q3. Write a function that adds two numbers.
Steps: Use function keyword, parameters, return result.
Solution: function add(a,b){ return a+b; }
Q4. Write a function that greets a user.
Solution: function greet(name){ [Link]("Hello " + name); }
Section 3: Arrays
Q5. Create an array of foods and print the first item.
Solution: let foods = ["Rice","Chicken","Fruit"]; [Link](foods[0]);
Q6. Loop through an array and print each item.
Solution: for(let i=0;i<[Link];i++){ [Link](foods[i]); }
Section 4: Objects
Q7. Create an object with name, age, and job.
Solution: let person = { name:"Jennifer", age:22, job:"Student" };
Section 5: Conditions
Q8. Check if a number is greater than 10.
Solution: let num = 15; if(num>10){ [Link]('Greater than 10'); }
Mini Practice Tasks
Task 1: Write a function that checks if a number is even or odd.
Task 2: Write a function that reverses a string.