0
initializing single object with function
https://sololearn.com/coach/609/?ref=app not sure how To CaLL VaIABLES In SiNGLE OBJECT INITIALIZATIoN
4 Respostas
+ 2
Your function has no return statement. And you should use `this` instead of `cuboid`. Also, parantheses are needed to call a function. It is cuboid.func() not cuboid.func. Lastly, it is not a class. It is an object.
https://code.sololearn.com/Wjrp01lHlq6S/
+ 1
alex
You can access properties from object in two ways:
1 - cuboid["length"]
2 - cuboid.length
+ 1
thanks!
0
to clerify, i am trying to call the value within a module of the class. i try using ‘this’ as well as the name if the class but with mo results
var cuboid = {
length: 25,
width: 50,
height: 200,
func: function (func) {cuboid.length * cuboid.width * cuboid.height};
//return this.length * this.width * this.height;
};
var x = cuboid.func
console.log(x);