Advertisement
Guest User

object test

a guest
Sep 20th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var accountInfo = {
  2.     users: [],
  3.     displayUsers: function () {
  4.         var i;
  5.         for (i = 0; i < this.users.length; i++) {
  6.             console.log(this.users[i]);
  7.         }
  8.     },
  9.     addUser: function(firstName, lastName, gender, age) {
  10.         this.users.push({
  11.             firstName: firstName,
  12.             lastName: lastName,
  13.             gender: gender,
  14.             age: age,
  15.             isVerified: false
  16.            
  17.         });
  18.         this.displayUsers();
  19.     },
  20.     showVerified: function() {
  21.         var i;
  22.         for (i = 0; i < this.users.length; i++) {
  23.             if (this.users[i].isVerified === true) {
  24.                 console.log(this.users[i]);
  25.             }
  26.         }
  27.     },
  28.     verifyUser: function(position) {
  29.         this.users[position].isVerified = true;
  30.         console.log("User Verified");
  31.         this.showVerified();
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement