0
I don't understand.
Everything I read tells me this is a problem with node.js. something about a server side? When I run this code I get, The item not defined error. It's driving me nutz. var cuboid = { length: 25, width: 50, height: 200, }; function vol(){ var x = cuboid.length; var y = cuboid.height; var z = cuboid.width; var v = x * y * z; //return v; }; return v; //console.log (v);
3 Respostas
+ 6
A function takes an input and give out an output. So in this case,
return v must be inside the function vol and not outside.
Now if you want to print what the function give out then you need to make a function like:
console.log(vol())
var cuboid = {
length: 25,
width: 50,
height: 200,
};
function vol(){
var x = cuboid.length;
var y = cuboid.height;
var z = cuboid.width;
var v = x * y * z;
return v;
};
console.log (vol());
0
Thank you. I don't understand why I have so much trouble passing values to functions and acting on the return values. It seems so straight forward.
0
that is my "child", as I understood how to access to the objects value and use them :)
var vol = (cuboid.length*cuboid.width*cuboid.height);
console.log(vol);