I am new to HTML, JavaScript and Stack Overflow. I am currently making a website for creating and saving recipes.
I have an input (with an ID of "ingredient.value") for ingredients, and an "Add Ingredient" button which adds the ingredient from the input to the recipe.
For example, you could write "Pasta" in the ingredient input, and then press "Add Ingredient" which would add pasta into an unordered list. Then if you put another ingredient such as "Tomato Sauce" and pressed "Add Ingredient" again, it would put Tomato Sauce in the same unordered list, below "Pasta".
Then I have a "Save Recipe" button which I want to use to save the recipe into local storage.
So, my question is:
How would I go about making the "Add Ingredient" button turn the input into an array of objects, for example like this:
let fullRecipes = [{ ingredients: ["Pasta", "Tomato Sauce"] }];
and then make the "Save Recipe" button lock, and save the object into local storage, and then move onto a new object. So that once a recipe has been saved, the next recipe would be a new object like this:
let fullRecipes = [
{ ingredients: ["Pasta", "Tomato Sauce"] },
{ ingredients: ["newIngredient1", "newIngredient2"] }
];
Any pointers on how I could achieve this are greatly appreciated. Thanks.