I'm making a journal app and need to create an object instance every time inputs are submitted on my html form.
I want to create a loop that takes the inputs in results and converts them to values in a new Object instance. My attempt at this so far gives me an instance with undefined values however. Is this even possible to do?
results = []
function example(a, b){
this.a = a;
this.b = b;
}
function getElements(){
var a = document.getElementById("a").value;
var b = document.getElementById("b").value;
results.push(a,b)
}
My attempt at a loop to create a new instance of example
function createNewDay(){
for (i = 0;i<results.length;i++){
var x = new day([i])
}
}
When I console.log => example{a:undefined, b:undefined}