let lettuceNeeded;
let tomatoNeeded;
let cucumberNeeded;
let dressingNeeded;
let servings;
let recipe;
function calcLettuce(numServings)
let numServings = 2;
let lettuce = 1;
let totalLettuce = lettuce * numServings;
return totalLettuce;
}
function calcTomato()
{
let tomato = .5;
let totalTomato = tomato * numServings;
return totalTomato;
}
function calcCucumber(numServings)
{
let cucumber = .25;
let totalCucumber = cucumber * numServings;
return totalCucumber;
}
function calcDressing(numServings)
{
let dressing = 1;
let totalDressing = dressing * numServings;
return totalDressing;
}
console.log(“~~~Welcome to the Recipe Calculator~~~”)
recipe = prompt(“Enter the name of your recipe: “);
servings = Number(prompt(“Enter the number of servings: “));
console.log();
lettuceNeeded = calcLettuce(servings);
tomatoNeeded = calcTomato(servings);
cucumberNeeded = calcCucumber(servings);
dressingNeeded = calcDressing();
console.log(“For ” + servings + ” servings of “+recipe+”, you will need to buy the following ingredients: “);
console.log(lettuceNeeded + ” cups of lettuce”);
console.log(tomatoNeeded + ” tomatoes”);
console.log(cucumberNeeded + ” cucumbers”);
console.log(dressingNeeded + ” ounces of dressing”);
The syntax it hard to find