Quote:
Originally Posted by devnull69
this is your code in a readable format
Code:
function getvolume(l, w, h) {
var v;
v= l * w * h;
return v;
}
var length, width, height;
length = parsefloat(prompt("enter length"));
width = parsefloat(prompt("enter width"));
height = parsefloat(prompt("enter height"));
getvolume(length, width, height);
function getweight() {
var w;
w = weight;
return w;
}
var weight;
weight = parsefloat(prompt("enter weight"));
if (v <= 1000000 && w <= 1000 ) {
alert("thank you for shipping with us!");
} else if (v >1000000 ) {
alert("your chocolates will not fit the container.");
} else (w > 1000) {
alert("your chocolates are to heavy for the container.");
}
it seems like you have problems understanding the concepts of "global and local variables" and "functions with return values".
1 - you are accessing the variable w in the global scope (i.e. Outside of any function). But you declared w to be local to the function "getweight". Outside of this function you neither declare nor define it, so it is undefined.
2 - you define a function getweight, but you never call it
3 - you define and call the function getvolume, but you don't assign the return value to any variable in your global scope. So the result (return value) is lost
can you work with this or do you need additional assistance?
|
thank you so much for your help and i think i will be needing a little more assistance with this as i see you slow walking me to an epiphany but need a more direct route there lol, and again thank you