Ask coding questions

← Back to all posts
I need help with this exercise i can not figure it out. :(
Iyehvah (1)

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;

It says the method should take a parameter and it should be a number. But where would i put the parameter? x_x iv rewatched the video linked to the exercise many times. Im probly just having a brainfart right now and the answer is super simple but i appreciate the help.

mwilki7 (152)

You can put all sorts of stuff into an object.

// each element of 'stuff' is separated by a comma
let something = 
    sum: function(a, b) { return a + b;}, // you can put functions into objects
    pi: 3.141596, // you can put numbers into objects
    anotherobj: { // you can even put other objects into objects
        phone: 123456
console.log(something.sum(something.pi, something.pi) + " " +;

output: 6.283192 123456

See if you can use the above information to do what you need to do.