Skip to content
Branch: master
Find file History
Chinkeki and basir implement project (#44)
* implement project

* Update chinkeki.html
Latest commit 284e4d6 Nov 5, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
Oluwaseyi.html chapters changed Oct 28, 2019

Project JavaScript H2 Objects

Topics: The this Keyword Arrow Functions and this, Privacy, Getters, Setters, Factory Functions, Property Value Shorthand, Destructured Assignment, Built-in Object Methods

Project Title: Student Informations

  1. Create a html file with your name like john.html
  2. Add current code to that file:
<!DOCTYPE html>
      // your code here
  1. Create a student object with id, firstName, lastName, major, _gpa fields and a method show that show student info like this: Name: {firstName lastName} (ID:{id} ) Major: {major} GPA: {gpa} Note: Use this keyword to access fields in show method.

  2. Define a getter method named fullName for student. If first name is empty return Mr/Ms {last name} else return {firstName} {lastName}.

  3. Define a setter method named gpa. If gpa is less than 0 or greather than 4 , log error else put it into _gpa field.

  4. Create a factory function named courseFactory. Use arrow function and pass parameters: id, name, credit. It should return an object with these field and method named show to log all field into console.

  5. Call this function with parameters (1, "Math", 3, ) and assign to myCourse variable. Show call and check the result.

  6. Check that myCourse has teacher property, if it has log teacher else log no teacher.

  7. Create another object named courseAddition and set it to {teacher: "Dr Mark"}

  8. Use object.assign to merge courseAddition into myCourse.

  9. Check that myCourse has teacher property, if it has log teacher else log no teacher.

  10. Show all fields and values into myCourse with object.keys

Want to get reviewed?

Send Pull Request. Check how to deliver your code:

Need help?

Download Learn JavaScript eBook from

You can’t perform that action at this time.