Help!! Losing my mind trying to solve this bootcamp prep course exercise
KuzcoJones (0)

function ClassOne(name, pw, mail){ let username = this.name; let password = this.pw; let email = this.mail;
// Exercise One: In this exercise you will be creating your own class!
// You are currently in the class, you are given three strings, name, pw, and mail.
// You need to create three properties on this class.
// Those properties are: 'username', 'password', and 'email'
// Set the value of username to name,
// Set the value of password to pw,
// Set the value of email to mail

// Note: Remember you DO NOT need to return anything in a class!
}

function ClassTwo(name, pw, mail){ let username = this.name; let password = this.pw; let email = this.mail;
let checkPassword = function (string){ return this.pw === password;

};
// Exercise Two: Now that you have created your own class,
// you will create a class with a method on it.
// In this class create 4 properties: username, password, email, and checkPassword.
// Set the value of username to name,
// Set the value of password to pw,
// Set the value of email to mail
// Set the value of checkPassword to a function.
// The checkPassword function takes a string as it's only argument.
// Using the 'this' keyword check to see if the password on the class is the same as
// the string being passed in as the parameter. Return true or false.
}

You are viewing a single comment. View All
Geocube101 (294)

Assuming JavaScript
Class parameters are placed inside the constructor function

class Test
{
  constructor(p1, p2, p3)
  {
    this.p1 = p1;
    this.p2 = p2;
    this.p3 = p3;
  }
}

If the exercise requires use of function instead of class then the first function is the constructor:

function test(p1, p2, p3)
{
  this.p1 = p1;
  this.p2 = p2;
  this.p3 = p3;
}

Adding functions to this class can be done with prototype

test.prototype.func1 = function(params)
{
  //Do Something Here
}