Uncaught SyntaxError: Unexpected ILLEGAL Token

May I know what's wrong with that. I am new to the programming world. So if you help me, that will be great. Error on line

arr [$ {i.count-1}] [1] = $ {employee.email};

Awaiting response. All code is as follows.

$(function() { var arr = new Array(); arr[0]=new Array(4); arr[0][0]=sathis; arr[0][1] =sathis@gmail.com ; arr[0][2]=namakkal; arr[0][3]=21; arr[1]=new Array(4); arr[1][0]=ganesh; arr[1][1] =gans@gmail.com ; arr[1][2]=karaikudi; arr[1][3]=22; arr[2]=new Array(4); arr[2][0]=karthik; arr[2][1] =karthik@yahoo.co.in ; arr[2][2]=trichy; arr[2][3]=25; var str="<table><tr><th>Name</th><th>Email</th><th>City</th><th>Age</th></tr><tr><td>"; $("#emp_name").change(function() { var i=$(this).val(); str=str+arr[i-1][0]+"</td><td>"+arr[i-1][1]+"</td><td>"+arr[i-1][2]+"</td><td>"+arr[i-1][3]+"</td><tr></table>"; $("#viewer").html(str); alert(str); }); }); 
+6
jquery token
source share
2 answers

You need quotes for strings. For example, you need arr[0][0]='sathis'; instead arr[0][0]=sathis;

In addition, there is an easier way to create arrays:

 arr[0] = ['sathis', ' sathis@gmail.com ', 'namakkal', 21]; 
+17
source share

As pointed out by [user: 638452], this may be a bad invisible character. Reverse by an invisible character, where Javascript told me that there was an error, and my code worked without changes.

0
source share

All Articles