(Minimal javascript experience)
Source pasted into Chrome JavaScript Console:
(function doesIconExist() {
var xPath = '//*[@id="downloadActivityIcon"]'
var nodes = document.evaluate(xPath, document, null, XPathResult.ANY_TYPE, null);
return (nodes.iterateNext() ? ‘present’ : ‘absent’);
}
)();
The console reports the subject error message and links to this:
–which I post as an image to show the squiggly red line.
I tried converting the ternary conditional to an if
statement:
if (nodes.iterateNext())
return 'present' ;
return 'absent' ;
but it generates the same error with the squiggly red line starting in the first return
under the first '
and extending through the semicolon.
2
Answers
As spotted by @Pointy, the single quotes in the
return
statement were of the slanted variety used in word processing. I have no idea how they became so, but correcting them to proper'
single quotes solves the problem.You can just replace the
`
by'
or by"
and your code could look like this :I personaly tried in my console and it’s working.