Remember to take your time and work through each question diligently! Test your code, make sure it works, and try to find ways to improve. Once you are happy and satisfied with your code, upload it to Github, then turn in your Github link at the bottom of the page!
Don't forget. Make sure this assignment is in it's own repository. Not mixed in with others!
1. Exploring JavaScript Objects
Objective: The aim of this assignment is to deepen understanding and proficiency in manipulating JavaScript objects, including creating objects, accessing properties and methods, using constructors, and working with prototypes.
Problem Statement: You are tasked with creating a JavaScript program that simulates a digital library system. The program should allow users to add new books, search for books by title or author, and display information about the library's collection.
Task 1: Create a constructor function for the Book
object with properties for title
, author
, and pages
.
Task 2: Implement a method within the Book
object to display book information.
Task 3 (Bonus): Create an array to store book objects and implement functions to add new books and search for books by title or author.
Task 4 (Bonus): Create functions that utilize the filter
method to filter out books that contain more than 100 pages and the map
method to add "Title: " and "Author: " to the book's title and author properties respectably.
Expected Outcomes:
After completing this assignment, students should be able to create objects using constructor functions in JavaScript.
Students should be proficient in adding properties and methods to objects using prototypes.
Students should be able to manipulate arrays of objects and implement functions to perform various operations on object data.
2. Exploring Objects and Math in JavaScript
Objective: The objective of this assignment is to enhance proficiency in working with JavaScript objects and utilizing the Math class for mathematical operations.
Problem Statement: You are tasked with developing a JavaScript program that simulates a simple banking application. The program should allow users to create accounts, deposit funds, withdraw funds, and calculate interest based on specified rates.
Task 1: Create a constructor function for the Account
object with properties for accountNumber
, balance
, and owner
.
Task 2: Implement methods within the Account
object to deposit and withdraw funds.
Task 3: Create a method to calculate compound interest based on the balance and specified interest rate. Allow users to pass a year parameter to your method that represents the # of years the money has been invested and an interest rate. The output should be rounded up to the nearest whole number (perhaps using the Math.ceil()). The formula for compound interest is...
A=P(1+nr)^nt
Where:
is the amount of money accumulated after n years, including interest.
is the principal amount (the initial sum of money).
is the annual interest rate (in decimal form).
is the number of times interest is compounded per year (you can use 1 for this example).
is the number of years the money is invested or borrowed for (this will be your parameter passed into the method).
Expected Outcomes:
After completing this assignment, students should be able to create objects using constructor functions and manipulate their properties and methods in JavaScript.
Students should understand how to perform basic mathematical operations and calculations using the Math class.
Students should be able to apply object-oriented principles and mathematical concepts to solve real-world problems, such as financial calculations in a banking application.