0% found this document useful (0 votes)
3 views3 pages

JavaScript Real World Mini Tasks

The document outlines a series of JavaScript mini tasks designed for beginners to practice fundamental concepts such as variables, data types, operators, conditionals, loops, functions, arrays, and objects. Each task provides specific instructions to create and manipulate data structures, implement control flow, and utilize array methods. Additionally, it includes a bonus challenge that combines filtering, mapping, and printing results from a list of student objects.

Uploaded by

chambiramla18
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

JavaScript Real World Mini Tasks

The document outlines a series of JavaScript mini tasks designed for beginners to practice fundamental concepts such as variables, data types, operators, conditionals, loops, functions, arrays, and objects. Each task provides specific instructions to create and manipulate data structures, implement control flow, and utilize array methods. Additionally, it includes a bonus challenge that combines filtering, mapping, and printing results from a list of student objects.

Uploaded by

chambiramla18
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JavaScript Mini Tasks - Real-World Practice (Beginner Level)

1. Variables & Constants

Create variables for a customer's name, the number of items in their cart, and the store's name. Use
let and const.

2. Data Types

Create a product with the following details:


- name: string
- price: number
- inStock: boolean
- discount: null
- category: undefined

3. Operators

Calculate the final price of a product:


- Price: 100
- Discount: 20
- Check if the final price is less than 80 and print a message.

4. Conditionals

Check if a student passed an exam.


If grade >= 10, print "Passed", otherwise print "Try again".

5. Loops

Loop through a warehouse and print shelf numbers from 1 to 10 using:


- A for loop
- A while loop
- A for...of loop on an array of shelf IDs

6. Functions

Write a function called sendEmail(name) that prints:


"Email sent to [name]"
Bonus: Rewrite it using an arrow function.

7. Arrays
Create an array of your 3 favorite pizzas.
Add "pepperoni", remove one pizza, and print the updated list.

8. Objects

Create a user object with name, email, and a method login() that prints:
"[name] has logged in."

9. forEach

Given a list of items in a shopping cart, print each item using .forEach().

10. map

You have a list of car prices in dollars. Use .map() to convert them to euros (multiply by 0.9).

11. filter

From a list of students with grades, use .filter() to select only those who passed (grade >= 10).

12. Scope

Create a variable inside a function and try to print it outside the function.
What happens? Why?

13. Value vs Reference

Copy a number variable and change the copy.


Copy an object and change a property on the copy.
Then check if the original variables changed.

14. Anonymous Function

Use setTimeout() with an anonymous function to print:


"Order confirmed!" after 2 seconds.

15. Callback Function

Create a calculate(a, b, operation) function that uses a callback.


Use it with two callback functions: add and subtract.

16. Destructuring

Given the object:


const product = { name: "Phone", price: 500 };
Use destructuring to extract the name and price into variables.
17. Template Literals

Print the message using a template literal:


"Thank you, Sara! Your total is $45."

18. Spread & Rest

Use the spread operator to combine two arrays of groceries.


Use the rest operator in a sum(...numbers) function to add all numbers.

19. Optional Chaining

Check if a user's address has a city using optional chaining:


user?.address?.city

20. for...in vs for...of

Use for...in to loop through keys of a hotel booking object.


Use for...of to loop through an array of guest names.

Bonus Challenge

You have a list of student objects.


- Filter the students who passed
- Use .map() to extract their names
- Use .forEach() to print: "Congrats [name], you passed!"

You might also like