Question: Purpose The purpose of this assignment is to utilize basic JavaScript, as learned in this class, to show knowledge on objects functions, variables, and more.

Purpose
The purpose of this assignment is to utilize basic JavaScript, as learned in this class, to show knowledge on objects functions, variables, and more.
Tasks
Credit Card Validation
You're starting your own credit card business. You've come up with a new way to validate credit cards with a simple function called validateCreditCard that returns true or false.
Here are the rules for a valid number:
Number must be 16 digits, all of them must be numbers
You must have at least two different digits represented (all of the digits cannot be the same)
The final digit must be even
The sum of all the digits must be greater than 16
The following credit card numbers are valid:
9999-9999-8888-0000
6666-6666-6666-1666
The following credit card numbers are invalid:
a923-3211-9c01-1112 invalid characters
4444-4444-4444-4444 only one type of number
1111-1111-1111-1110 sum less than 16
6666-6666-6666-6661 odd final number
Hint: Remove the dashes from the input string before checking if the input credit card number is valid. (check out split() and join() methods.
3 points extra: Make your credit card scheme even more advanced! What are the rules, and what are some numbers that pass or fail? Ideas: check the expiration date! Check out the Luhn Algorithm for inspiration.
The Cash Register
Implement a class called Item
Item class should have the following fields: name, price
------------------------------------------------------------------------------
Implement a class called ShoppingCart
ShoppingCart class should have an array of items
ShoppingCart class should a method called addItem, which adds a new item to the shopping cart. The addItem method should accept one argument (e.g. item) and it should add that item into the array.
-----------------------------------------------------------------------------
Write a function called that accepts a ShoppingCart object. The function should return the total price of the shopping cart. This function should be outside of both ShoppingCart and Item classes.
Create multiple instances of the shopping cart object and show the results for each instance in your choice of display.
Examples:
Here are a few examples of unit tests
const item1= new Item("apple",5);// apple is the name, 5 is the price
const item2= new Item("carrot",.45);
const item3= new Item("shirt",55);
const cart = new ShoppingCart();
cart.addItem(item1);
cart.addItem(item2);
cart.addItem(item3);
Bonus (Extra 3 points): Update your Shopping Cart Object to add a taxable field to each item in the cart. Update your cashRegister function to apply 10% tax to the taxable items only, and outputs the correct total. Create multiple instances of the shopping cart object and show the results for each instance in your choice of display.
Acceptance Criteria
Your code must be appropriately commented. Any variables, functions, objects, or algorithms that are not obvious, must be commented on.
Your code must output the required output.
Completion
submit JavaScript file(s) with the name lastname_firstname_assignment5.js or copy and paste your code into Canvas so that your instructor can run them successfully in Visual Studio Code. No HTML is needed for this assignment. You can use the console.log to test your program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!