elena1234

From JSON to HTML - JavaScript

Aug 30th, 2021 (edited)
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(array) {
  2.     let employees = array.map(x => JSON.parse(x));
  3.  
  4.     let html = '<table>';
  5.     employees.forEach(currentEmployee => {
  6.         html += `\n\t<tr>${Object.values(currentEmployee).map(x => `\n\t\t<td>${x}</td>`).join('')}\n\t</tr>`;
  7.     });
  8.  
  9.     html += '\n</table>';
  10.     console.log(html);
  11. }
  12.  
  13. solve(['{"name":"Pesho","position":"Promenliva","salary":100000}',
  14. '{"name":"Teo","position":"Lecturer","salary":1000}',
  15. '{"name":"Georgi","position":"Lecturer","salary":1000}']
  16. )
Add Comment
Please, Sign In to add comment