Let's breakdown your code to see how JavaScript interprets it:
var app = "<a onclick='openApp('"+url+"')">"+icon+"</a>"
var // declare variable using var keyword
app // variable name is "app"
= // assignment operator
"<a onclick='openApp('" // string with HTML tags and function call
+ // concatenate operator
url // variable named "url"
+ // concatenate operator
"')" // closing of the function call string
> // HTML tag <
"+icon+" // concatenate icon variable in double quotes
< // HTML tag <
/ // divide or start of regex literal?
a // variable named "a"
> // HTML tag >
" // opening double quote without closing!
From this breakdown, you can see there is a syntax error in your code. It seems like your actual code should be something like this (or maybe your JS engine automatically corrected it):
var app = "<a onclick='openApp('" + url + "')>" + icon + "</a>"
Although this code is syntactically correct, it produces invalid HTML:
<a onclick='openApp('https://classroom.google.com')>
<i class="fas fa-chalkboard-teacher"></i>
</a>
The issue here is that the single quote around 'https://' within the `onclick` attribute is causing improper parsing by the HTML parser. To resolve this, consider using double quotes for `onclick` value instead of single quotes. This can be done using escape sequences like `\"`.
var app = "<a onclick=\"openApp('" + url + "')\">" + icon + "</a>";
By making these adjustments, your HTML will now render correctly as follows:
<a onclick="openApp('https://classroom.google.com')">
<i class="fas fa-chalkboard-teacher"></i>
</a>