JSFiddle - React, Tailwind, and code Playground

by velo_ninja

HTML

<button onclick="printObject()">Print Object</button>

JavaScript

function printObject() {
    // Sample object
    const obj = { foo: 'bar', baz: 'qux' };

    // Convert object to HTML
    let html = '<ul>';
    for (const key in obj) {
        html += `<li><strong>${key}:</strong> ${obj[key]}</li>`;
    }
    html += '</ul>';

    // Print the HTML content
    printJS({ printable: html, type: 'html' });
}