JavaScript for Beginners #47 Coding Challenge 7

Опубликовано: 27 September 2026
на канале: GreeneMath.com
342
10

Here, we will look at a simple coding challenge that asks us to create a constructor function that will create an object for each customer at a restaurant.

//Set up a constructor function that creates a new object with the first name and last name of the customer, the subtotal, the tax rate, and the level of service they received: good or excellent
//Next, set up methods that gives the full name, the tip, and the tax. If the person recieved good service, the tip percentage should be 18%, if the person recieved excellent service, it should be 25%.
//Lastly, set up a method that calculates the total bill and returns a receipt with the customer's full name.
//Test Data: "Mary", "Beth", 200, .1, "excellent"
//Test Data: "Becky", "Anderson", 100, .05, "good"

0:00 Instructions for our coding challenge
1:47 Setting up a constructor function
3:40 Testing our function
4:26 Setting up the getFullName method
5:20 Setting up the getTax method
6:18 Setting up the getTip method
7:46 Setting up the getTotalBill method
10:00 Viewing our first customer receipt
10:55 Viewing our second customer receipt


JavaScript Playlist:
   • JavaScript for Beginners  

MDN Constructor:
https://developer.mozilla.org/en-US/d...

W3 Schools Constructors:
https://www.w3schools.com/js/js_objec...

MDN Objects:
https://developer.mozilla.org/en-US/d...

NodeJS:
nodejs.org

VS Code: