Ummm... Somewhat Complicated


#1

The objective is only to get a number for an answer from the prompt, otherwise to ask again if any other value than a numeric value is entered, and then to multiply those numbers as a mathematical operation.

var areaBox = function(length, width) {
    return (length * width);
};
console.log(areaBox(
    prompt("Pick a length... for your imaginary rectangle"),
prompt("Pick a width for your imaginary rectangle... and you shall be presented with the area!")))

Any help would be greatly appreciated.


#2

Where is this function defined?


#3

Update: How about now?


#4

Suggestion: deconstruct your console.log() statement, it looks confusing.

var boxL = prompt("Pick a length... for your imaginary rectangle");
var boxW = prompt("Pick a width for your imaginary rectangle... and you shall be presented with the area!");

console.log(areaBox(boxL, boxW));

Doesn't it look much cleaner?


To check where the input is a number or not, you can use Number object and one of its methods:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.