Параметр внутри метода для javascript - PullRequest
0 голосов
/ 29 мая 2020
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(myNumber){
      myNumber * 2;
    }
  };
  return mathHelpers;
}

Возвращается неправильно. Застрял на этом 90 минут. Что я делаю не так?

Это код до того, как я над ним работал

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.

  };
  return mathHelpers;
}

1 Ответ

0 голосов
/ 29 мая 2020

В любом случае я подумал, спасибо, лол

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(myNumber = 4){
      return myNumber * 2;
    }
  };
  return mathHelpers;
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...