A friend wrote some code for me, and there was one file with a weird syntax error in it. After a bit of hunting, I narrowed it down to this section of code, which should rep
Your issue is the fact that the i
in function is the unicode character i
. If you change it to a 'normal' i
it should just work.
But now I'm wondering how the hack :) did you get an unicode character there :P
I copied your code into jsfiddle, and Chrome too gives an error. I deleted the word "function", and re-typed "function", and it worked fine.
There must be some extra character there.
I had a similar problem and the same error code when debugging someone else's work. To fix this I pasted the section of code into Notepad and then re-copied it back to Visual Studio. The error went away. I think whoever wrote the code originally must have copied it from somewhere with some strange characters in it.
I've copied and pasted it in my notepad++ and your code look like this in my notepad++, retype your function keyword, i is replaced by ?.
var say = funct?on(message) {
alert(message);
return message;
};
say(say("Goodbye!"));
In fact, you inserted unicode "i" instead of normal "i".
I get the fellow errors in VSCode:
',' expected. (1, 29)
',' expected. (2, 10)
Declaration or statement expected. (4, 3)
You can try evaluating "functіon" == "function"
as well:
function compare() {
return "functіon" === "function"
}
console.log(compare())
function compare2() {
return "function" == "function"
}
console.log(compare2())
You have misspelled the "function" :)
var say = function(message){
alert(message);
return message;
};
say(say("Goodbye!"));
You have inserted functіon
:)