Answer:
function decision(car_price, available_cash) {
if(car_price <= available_cash) {
console.log("no");
}
else {
console.log("yes");
}
}
decision(car_price, available_cash); or decision(available_cash, car_price);
Explanation:
using functions in Javascript:
functions; this refers to dividing codes into reusable parts.
e.g function function_name() {
console.log("How are you?");
}
you can call or invoke this function by using its name followed by parenthesis, like this: function_name(). each time the function is called it will print out "How are you?".
Parameters: these are variables that act as placeholders for the values that are to be input into a function when it is called
Arguments: The actual values that input or passed into a function when it is called.
e.g
function function_name(parameter1, parameter2) {
console.log(parameter1, parameter2);
}
then we call function_name: function_name("please", "leave"):we have passed two arguments, "please" and "leave". Inside the function parameter1 equals "please" while parameter2 equals "leave".
Hence, from the question given the two parameters "car_price" and "available_cash" respectively, we write the function with name function_name:
function decision(car_price, available_cash) {
if(car_price <= available_cash) {
console.log("no");
}
else {
console.log("yes");
}
}
decision(car_price, available_cash); or decision(available_cash, car_price);