Help, I can't fix this function! Please help

javascript

#1

confirm ("Hello and thank you for using my first and probably only 'Homework Machine'!")
confirm ("It is currently in a beta state and is being updated regularly.")
confirm ("The point of this program is to help you out in the painfully long process of homework. It consists of multiple features: Addition, Subtraction, Multiplication, Division, Area, and Perimeter. These features may seem simple and make this program useless but again, features are constantly being worked on.")
var userChoice = prompt("OK let's get started! type in the function you want the program to work on.")
if (userChoice === "Addition", "addition")
{
var Addition = function (number, number) {
return (number) + (number)
}
var number = prompt("Type in the first digit you want the program to work on.")
var number = prompt("Type in the other digit you want the program to add with the first")
confirm(Addition(number, number))
}

It would not confirm the function's answer correctly.
Please help make this add the numbers correctly.


#2

You have a lot of problems here...

Here are some
1. Your if condition is incorrect, you cannot have it syntaxed that way or it will be always true.
2. Your using the same variable for everything
3. Prompt() alwasy returns a string value, so before you can do any math on it you have to convert it to a number.

Here is what I think you're trying to do, I just re-wrote it to something more functional.

var userChoice = prompt("OK let's get started! type in the function you want the program to work on.");

var Addition = function(number1, number2) {
    return (number1 + number2);
};

if (userChoice === "Addition" || userChoice === "addition") {
    var first = prompt("Type in the first digit you want the program to work on.");
    var second = prompt("Type in the other digit you want the program to add with the first");
    num1=Number(first);
    num2=Number(second);
    alert(Addition(num1,num2));
} else {
    alert("Sorry I don't know that function");
}

#3

Hey thanks, I saw u used many semicolons and I know it's said to be important to add semicolons. HOW does it make a difference and where do u put them?