Pages

Monday, May 1, 2023

One-Prompt Epoetry in ChatGPT

 Type this into ChatGPT:

Today, we're going to create a computer program that demonstrates metanymic substitution. We'll use JavaScript and HTML to do this. The word we will be using as our primary word is IT. We will define five possible substitutions. The program will randomly select a fragment of the primary word. So, first, create an HTML and JavaScript program that displays the word "IT" on the screen. Define a button that will allow the user to run the metonymic substitutor. When the user clicks the button, the program will select one of five substitutions: 1. ((IT)) 2. (I(T)) 3. (I)(T) 4. ( IT ) 5. ()IT() The program will swap out the randomly selected segment of the primary word with a randomly selected substitution, then update the page to show the new word. It will make this code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Metonymic Substitution</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
        }
    </style>
</head>
<body>
    <h1>Metonymic Substitution</h1>
    <p id="word">IT</p>
    <button onclick="substitute()">Substitute</button>

    <script>
        function getRandomInt(max) {
            return Math.floor(Math.random() * max);
        }

        function substitute() {
            const substitutions = [
                '((IT))',
                '(I(T))',
                '(I)(T)',
                '( IT )',
                '()IT()'
            ];

            const wordElement = document.getElementById('word');
            const currentWord = wordElement.textContent;

            const randomIndex = getRandomInt(substitutions.length);
            const selectedSubstitution = substitutions[randomIndex];

            const fragment = currentWord === 'IT' ? 'IT' : currentWord.charAt(getRandomInt(currentWord.length));
            const newWord = currentWord.replace(fragment, selectedSubstitution);

            wordElement.textContent = newWord;
        }
    </script>
</body>
</html>

You can watch the code go here:

Metonymic Substitution

Metonymic Substitution

IT

No comments:

Post a Comment