'Adding function to td table in javascript

I'm new to js and looking for someone to help me with it. I have created javascript table with the following code:

data = { players: [
  { name: 'aphra', score: 10, ping: 20 }
] };

const addRow = (el, data) => {
  if (data.players.length) {
    data.players.forEach((ply) => {

      const row = document.createElement("tr");
      row.innerHTML = `
                <td>${ply.name}</td>
                <td>${ply.score}</td>
                <td>${ply.ping == '0' ? 'BOT' : ply.ping}</td>
              `;
      el.appendChild(row);
    });
  }
};
const table = document.getElementById('id')
addRow(table, data);
<table id="id"></table>

I'm trying to apply given below code function with the <td>${ply.name}</td> in my table js

js code function I want to apply https://jsfiddle.net/tdwcqze0/



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source