I am trying to use ChatGPT to create a very simple Javascript example as an initial test.
I created this script in Keyboard Maestro using Execute Javascript in Google Chrome:
var states = ["Alabama", "Alaska", "Arizona", "Arkansas", "California"];
var capitals = ["Montgomery", "Juneau", "Phoenix", "Little Rock", "Sacramento"];
var table = "<table>";
table += "<tr><th>State</th><th>Capital</th></tr>";
for (var i = 0; i < states.length; i++) {
table += "<tr><td>" + states[i] + "</td><td>" + capitals[i] + "</td></tr>";
}
table += "</table>";
alert(table);
The result is an alert box which shows the raw generated HTML.
How do instead alter the script to open a new tab in Chrome and render the HTML there?
Any idea how to structure the ChatGPT request so ChatGPT proposes a script which runs as-is in the desired fashion?