javascript - Trying to add an array to an array if the array being added is not in the array already -
what trying add array after event if event occurred once press of enter button. if user keeps on entering wrong answer should update array once array represents question. if can me out this question deals more of trying do great.
if cant me wondering how insert array after event if array isn't in array. can show me code search array inside of array , if array inside or nothing?
i don't understand why in below code not able search arrays
function onlyunique(value, index ,self){ return self.indexof(value) === index; } var = ['a' , [1], [1],'a'] var unique = a.filter(onlyunique) console.log(unique)
you use object associative array. need way identify questions link answers.
// answers storage var answers = {}; // set answer question 1, replaced automation var questionid = 'q1'; var data = 'some answer'; // insert if not present if(answers[questionid] === undefined) { answers[questionid] = data; } // manipulate existing answer else { // answers[questionid] }
Comments
Post a Comment