-1

I don’t know how this code is working and it’s jQuery or JavaScript.

Here in this code, what does this ` symbol signify? If I am replacing it with ' then it’s not giving me output.

The other problem is count is declared above and its now id so how can we use ${count} how it is getting value, what I have studied var myElement = document.getElementById("id"); and var myElement = $("#id"); are same but it works on id and count here is const not id.

const count = counter[member.assigned];

trHTML += `<tr><td rowspan=${count}>${member.assigned}</td><td>${member.assigned}</td></tr>`;
WhiteWalker
  • 179
  • 1
  • 3
  • 14
  • 1
    The back tick is used for string interpolation and replaces the more traditional `let myvar = variable + "string";` – Bibberty Jan 13 '19 at 07:04
  • See [What does this symbol mean in JavaScript?](https://stackoverflow.com/q/9549780/4642212) and the documentation on MDN about [expressions and operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators). – Sebastian Simon Jan 13 '19 at 07:04
  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals – Dmitry Jan 13 '19 at 07:04

1 Answers1

1

These are javascript template string literals. They allow expressions to be easily inserted into strings.

const foo = 'foofoo';
const bar = 'barbar';

console.log(`What is a ${foo} or ${bar}?`); // values inserted into string
Drew Reese
  • 43,833
  • 5
  • 21
  • 43