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?
5 Respostas
+ 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.
+ 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.
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.đ
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?
0
var cuboid = {
length: 25,
width: 50,
height: 200
};
//your code goes here
console.log(cuboid.length*cuboid.width*cuboid.height)