-
Notifications
You must be signed in to change notification settings - Fork 0
/
q44.ts
16 lines (15 loc) · 848 Bytes
/
q44.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Sandwiches: Write a function that accepts a array of items a person wants on a sandwich. The function should have one parameter that collects as many items as the function call provides, and it should print a summary of the sandwich that is being ordered. Call the function three times, using a different number of arguments each time.
export default function q44(){
function makeSandwich(...ingredients: string[]) {
console.log("Making a sandwich with the following ingredients:");
ingredients.forEach(function(ingredient){
console.log("- " + ingredient);
})
console.log("Enjoy your sandwich!\n");
}
// Call the function with different numbers of arguments
makeSandwich("bread", "cheese", "ham");
makeSandwich("bread", "peanut butter", "jelly");
makeSandwich("bread", "turkey", "lettuce", "tomato", "mayo");
}
q44();