How can I make Javascript check an array and make sure that there\'s no error committed after the comma separating each element of the array .. For example a user may form an ar
Given that you are trying to validate user-entered data, I'd suggest reevaluating your approach.
You should not require end-users to enter data in valid JavaScript syntax; this is annoying to your users.
Instead, I'd just have a textarea and instructions.
This is far easier for humans to deal with, and parsing is super simple:
var cars = document.getElementById('carstextarea').value.split('\n');
// => ["Saab","Volvo","BMW"]