0% found this document useful (0 votes)
6 views

Js Assignment

Uploaded by

Lakhan Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Js Assignment

Uploaded by

Lakhan Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

JAVASCRIPT ASSIGNMENT

1. Write a function that takes two numbers and returns their sum.
2. Write a function that takes an array of numbers and returns the largest number.
3. Write a script that checks if a number is even or odd.
4. Write a loop that prints numbers from 100 to 90.
5. Create an object representing a book with properties like title, author, year Published, and
genre.
6. Write a method within the object that prints a summary of the book.
7. Demonstrate type conversion between different data types (e.g., string to number, number
to Boolean).
8. Create a class Person with properties for name and age.
9. Add a method greet that prints a greeting message.
10. Create a subclass Student that extends Person and adds a property for grade. Override the
greet method to include the student's grade in the message.
11. Write a function to handle a condition which throws an exception
12. Create a function that returns a promise which resolves after 2 seconds with a success
message.
13. Chain a .then method to log the success message and a .catch method to handle any errors.
14. Rewrite the above function (point 12) using async and await.
15. Create two files, math.js and app.js.
16. In math.js, export functions for addition and subtraction.
17. In app.js, import these functions and use them to perform some calculations
18. Create a form with an input field and a submit button.
19. Write JavaScript to prevent the form from submitting if the input field is empty and display
an error message.
20. Write a code which will print first letter of your name using * in console (rows and column
length is optional).
21. Create a calculator which will perform some operations like add, subtract, divide, multiply
and it should support the bodmass rule as well.

NOTE: Question number (20, 21) is must to completed in this assignment.

You might also like