Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当我运行此代码时,我';我没有收到任何输出,请给我任何建议或更正_Javascript - Fatal编程技术网

Javascript 当我运行此代码时,我';我没有收到任何输出,请给我任何建议或更正

Javascript 当我运行此代码时,我';我没有收到任何输出,请给我任何建议或更正,javascript,Javascript,这段代码有什么问题?我的输出没有定义 function ClassOne(name, pw, 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 t

这段代码有什么问题?我的输出没有定义

function ClassOne(name, pw, 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

    this.ursername = name;
    this.password = pw;
    this.email = mail;


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

    function ClassTwo(name, pw, mail){
      // 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.

    this.username = name;

    this.password = pw;

    this.email= mail;

    this.checkPassword = function (string) {

    return `${this.password}`;

      }
    }


// This code below output the first exercise which was ok but the second exercise is not showing any output.

 function exerciseOne(){
  // Exercise One: In this exercise you are given an object called 'mathHelpers'
  // Within mathHelpers, create a method called 'double'
  // This method should take one parameter, a number, 
  // and it should return that number multiplied by two.
  let mathHelpers = {
    // Create double method in here.
    double: function(number){
      return number * 2;
    }
  };
  return mathHelpers;
}

function exerciseTwo(userObj){
// Exercise Two: You will be given an object called 'userObj'
// userObject will already have a key on it called 'name'
// Add a method to userObj, called 'greeting'.
// Using the keyword 'this', the greeting method should return the following string:
// 'Hi, my name is ' and the users name.
// eg: If userObj has a name: 'Dan', greeting should return: Hi, my name is Dan'
// NOTE: DO NOT create a new object.
// NOTE: DO NOT create a key called name the key is already on the object.
userObj = {

greeting:function() {
return `Hi, my name is: ${this.username}`;
   }
};

  // Please write all of your code on the lines above.

}

此密码必须为true

应该如此

返回this.password==string或返回this.password==newPassword