Need help with assignment 12: Lambda
FINALBOSS (5)

In assignment 12 of the precourse, I'm asked to demonstrate the proper use of methods in the javascript language. The lesson in accordance to this assignment also covers loops and .this. I'm not sure if I have to demonstrate those for exercise one, but we'll see.

Anyways, I'm already given an object called mathHelpers. I have to create a method within the object and call it 'double'. The double method must take one parameter, a number and the number must be returned with a multiple of 2.

Problem: I don't know if I'm overthinking it or what, but everything I try doesn't seem to work. I keep getting the unidentified error after declaring the method as a function and writing the code within.

code

function exerciseOne(){

  let mathHelpers = {
 
double : function (numX) {

return mathHelpers.double(5) * 2;

                                }
};
  }
You are viewing a single comment. View All
mwilki7 (410)

Did you try:

function exerciseOne()
{
    ... // other code here
    mathHelpers.double = function(num)
    {
        return num * 2;
    };
}
FINALBOSS (5)

It gave me errors when I tried that. @mwilki7

mwilki7 (410)

@FINALBOSS
What do they errors say?

FINALBOSS (5)

It doesn't give me errors when I take the function you gave me out of the mathHelpers object and fix up a few loose semicolons and brackets.
However, the point of the assignment is to write code within mathHelpers object. @mwilki7