I don't understand. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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);

17th May 2021, 4:09 AM
Paul Hudson
Paul Hudson - avatar
3 Answers
+ 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());
17th May 2021, 4:27 AM
Rohit Kh
Rohit Kh - avatar
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.
20th May 2021, 2:52 AM
Paul Hudson
Paul Hudson - avatar
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);
30th Aug 2021, 9:17 PM
Pawel