Candy weighs X grams, tangerine - Y grams and apple - Z grams.
Need to write a program that will determine how many different versions of gifts weighing exactly W grams can make Santa Claus.
Function should receive four integers X, Y, Z and W.
Function should return a single integer - the number of gift options.
X = 10
Y = 25
Z = 15
W = 40
Result: 3
вот что я смог сделать:
let candy = 10;
let tangerine = 25;
let apple = 15;
let weight = 40;
let num; // the number of gift options
function Gifts(candy, tangerine, apple, weight) {
if (candy + tangerine <= weight) {
num = 1;
}
if (candy + apple <= weight) {
num = 1;
}
if (tangerine + apple <= weight) {
num = 1;
}
num = 1 + 1 + 1;
console.log(num);
}
Gifts();