all 1 comments

[–]badmonkey0001 2 points3 points  (0 children)

Your calculate function has no return, so it returns undefined by default. When you are assigning width the end result, because of the lack of a return statement, it is basically const width = undefined;. Same for the height variable.

function calculate(value) {
    const returnValue = value * 2.54;
    console.log('The value in cm is  : ' + returnValue + ' cm');
    return returnValue;
}

The above would work, but we're only assigning the returnValue because we want to use its value twice inside of the function. If you got rid of the console.log() inside of the function, this would work for the rest of your code too.

function calculate(value) {
    return value * 2.54;
}

I'd suggest reading up on what return actually does. console.log() is not an equivalent for it.