How could I manipulate this array in Javascript for this kind of error checking?

前端 未结 4 1809
时光取名叫无心
时光取名叫无心 2021-01-28 05:47

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

4条回答
  •  旧巷少年郎
    2021-01-28 06:53

    Your second cars example with the * in it won't compile.

    To check for double commas, you can iterate over the array and check for an undefined value.

    for(var i = 0; i

    Alternatively you could try and catch this before you generate the array. Is there a way to check for an empty row inputted by the user?

提交回复
热议问题