I am struggling with understanding functions, parameters, and arguments in JavaScript as I am new to it.
My goal is to have a function that returns different values based on the payment amount. If no payment is passed, it should return "Payment Required", if the payment is less than 1000, it should return "Payment Insufficient", and if the payment is sufficient, it should return "OK".
var shipping = function(letters, boxes, payment){
if (payment < 1){
return "Payment Required";
}
else if (payment < 1000) {
return "Payment Insufficient";
}
else {
return "OK";
}
};
This code snippet defines the 'shipping' function.
var delivery = function(letters, speed) {
if (letters.length > 5){
return shipping(letters, null, 1000);
}
};
var sendMail = function(letter) {
delivery([letter], "slow")
};
var shipping = function(letters, boxes, payment){
if (payment < 1){
return "Payment Required";
}
else if (payment < 1000) {
return "Payment Insufficient";
}
else {
return "OK";
}
};
However, I receive an error stating: "ReferenceError: fedEx is not defined"