0

[Introducing Objects] [JavaScript] Question

Hi all😃, the code doesn’t work, pls help 🙏. var cuboid = { length: 25, width: 50, height: 200 }; //your code goes here Function volume( length, width, height){ var volume = cuboid.length*cuboid.width* cuboid.height; return volume; } Console.log(volume(cuboard.length, cuboid.width,cuboid.height)); —————————————————- ISSUE: I know that “Objects are variables too, but they can contain many values”, but I don’t get the concept yet, and how to access the object?

18th Oct 2021, 7:49 AM
Liangyong Peng
Liangyong Peng - avatar
5 Antworten
+ 3
Liangyong Peng What is the use of function parameters? Did you check spelling of cuboard? ---------- var cuboid = { length: 25, width: 50, height: 200 }; //your code goes here function volume(length, width, height) { return length * width * height; } console.log(volume(cuboid.length, cuboid.width, cuboid.height)); ----+++-------There are two ways to access objects data------ console.log(volume(cuboid.length, cuboid.width, cuboid.height)); console.log(volume(cuboid['length'], cuboid['width'], cuboid['height'])); Both will give same results.
18th Oct 2021, 8:32 AM
A͢J
A͢J - avatar
+ 3
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ Thank you for correcting me. There should be a linguistic misunderstanding here. I didn't notice that I wrote it wrong so I didn't understand what you meant, but now I understand, my mistake.
18th Oct 2021, 10:59 AM
Liangyong Peng
Liangyong Peng - avatar
0
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ Hi AJ, Nice to see you again, what do you mean did I check spelling of cupboard? I am a beginner and am learning programming syntax by putting together answers from the pervious discussion strings(which is not working). Thank you for the very helpful answer (which is working prefectly), I believe your answer can help many other people as well.👍
18th Oct 2021, 9:14 AM
Liangyong Peng
Liangyong Peng - avatar
0
Liangyong Peng There is no doubt you are beginner but what you have written atleast you should verify. As per your given Code I found the mistake so I told you. I did anything wrong here If I asked about your mistakes?
18th Oct 2021, 9:34 AM
A͢J
A͢J - avatar
0
var cuboid = { length: 25, width: 50, height: 200 }; //your code goes here console.log(cuboid.length*cuboid.width*cuboid.height)
25th Jan 2023, 1:20 PM
a a
a a - avatar