I am trying to make a simple piece of JavaScript code, where the user puts in the length and width of a box, and the computer calculates the area of the box for them. What I did is assign the function parameters to (length, width) and then I made two variables that would be assigned to what the user put in for the length and width. After the user has input the length and width, I called the function and assigned it's parameters to the two length and width variables. Next I made a confirm part, that took the end result of the function and displayed it.
//Telling the computer what to do with the length and width.
var area = function (length, width) {
return length * width;
};
//Asking the user what the length and width are, and assigning the answers to the function.
var l = prompt("What is the length of the box?");
var w = prompt("What is the width of the box?");
area(l, w);
//Showing the end-result.
confirm("The area is:" + " " + area);
What happens is, the end result shows
The area is: function (length, width) { return length * width;\ }
So the end result of the code is showing the stuff to the right of the equals sign, as if what is written there is a string. Can anyone help out?