Javascript help needed plz

how do I create a method with this here?

 // 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.

function exerciseOne(){
  let mathHelpers = {
    // Create double method in here.
       }
    }
  };
  return mathHelpers;
}

a method is an object property that is a function, so you need to give that object a property with a value of function

try do it yourself

ill defently do it my self, but in order to use a method in this case, doesnā€™t there have to be a key:value within the object to use methods? cuase here it isnā€™t asking for key:value

yeah sorry im just trying to get as much advice as possible about methods, since im having a hard time finding info about how methods are used in my situation

function exerciseOne(){
  let mathHelpers = {
    double(number) {
      return number * 2;
    }
  };
  return mathHelpers;
}

hope this helpsļ¼

1 Like

but what does it mean by one parameter, a number

The double function accepts one parameter, the name of the parameter is name, and the type of this parameter is number.