Skip to content
The Chat Archive
Claudeclaude-3-5-sonnet-20241022· Anthropic LMArena Human Preference 140K

Build me todo app in Svelte ruins

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Qwenqwen3-235b-a22b-no-thinking’s answer.
  1. User

    Build me todo app in Svelte ruins

  2. Assistant

    I'll help you create a simple todo app using SvelteKit. Here's a basic implementation:

    <!-- src/routes/+page.svelte -->
    <script>
      let todos = [];
      let newTodo = '';
    
      function addTodo() {
        if (newTodo.trim()) {
          todos = [...todos, { 
            id: Date.now(), 
            text: newTodo, 
            completed: false 
          }];
          newTodo = '';
        }
      }
    
      function deleteTodo(id) {
        todos = todos.filter(todo => todo.id !== id);
      }
    
      function toggleTodo(id) {
        todos = todos.map(todo => 
          todo.id === id 
            ? { ...todo, completed: !todo.completed }
            : todo
        );
      }
    </script>
    
    <main class="container">
      <h1>Todo App</h1>
      
      <div class="input-group">
        <input
          type="text"
          bind:value={newTodo}
          placeholder="Add a new todo"
          on:keydown={e => e.key === 'Enter' && addTodo()}
        />
        <button on:click={addTodo}>Add</button>
      </div>
    
      <ul class="todo-list">
        {#each todos as todo (todo.id)}
          <li class:completed={todo.completed}>
            <input
              type="checkbox"
              checked={todo.completed}
              on:change={() => toggleTodo(todo.id)}
            />
            <span>{todo.text}</span>
            <button on:click={() => deleteTodo(todo.id)}>Delete</button>
          </li>
        {/each}
      </ul>
    </main>
    
    <style>
      .container {
        max-width: 600px;
        margin: 0 auto;
        padding: 20px;
      }
    
      .input-group {
        display: flex;
        gap: 10px;
        margin-bottom: 20px;
      }
    
      input[type="text"] {
        flex: 1;
        padding: 8px;
      }
    
      .todo-list {
        list-style: none;
        padding: 0;
      }
    
      li {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px;
        border-bottom: 1px solid #eee;
      }
    
      .completed span {
        text-decoration: line-through;
        color: #888;
      }
    
      button {
        padding: 8px 16px;
        background: #4CAF50;
        color: white;
        border: none;
        border-radius: 4px;
        cursor: pointer;
      }
    
      button:hover {
        background: #45a049;
      }
    </style>
    

    This creates a basic todo app with the following features:

    • Add new todos
    • Mark todos as complete/incomplete
    • Delete todos
    • Persistent list display
    • Basic styling

    To use this, you'll need to:

    1. Create a new SvelteKit project:
    npm create svelte@latest my-todo-app
    cd my-todo-app
    npm install
    
    1. Replace the contents of src/routes/+page.svelte with the code above

    2. Run the development server:

    npm run dev
    

    Would you like me to add any additional features like local storage persistence or filtering options?

  3. User

    Give me something I can run in browser

  4. Assistant

    Here's a complete single-file version you can run directly in the browser. Save this as index.html and open it:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Todo App</title>
        <script src="https://unpkg.com/svelte@4"></script>
    </head>
    <body>
        <div id="app"></div>
    
        <script type="module">
            import { compile } from 'https://unpkg.com/svelte@4/compiler.mjs';
    
            const app = new (eval(compile(`
                <script>
                    let todos = [];
                    let newTodo = '';
    
                    function addTodo() {
                        if (newTodo.trim()) {
                            todos = [...todos, { 
                                id: Date.now(), 
                                text: newTodo, 
                                completed: false 
                            }];
                            newTodo = '';
                        }
                    }
    
                    function deleteTodo(id) {
                        todos = todos.filter(todo => todo.id !== id);
                    }
    
                    function toggleTodo(id) {
                        todos = todos.map(todo => 
                            todo.id === id 
                                ? { ...todo, completed: !todo.completed }
                                : todo
                        );
                    }
                </script>
    
                <main class="container">
                    <h1>Todo App</h1>
                    
                    <div class="input-group">
                        <input
                            type="text"
                            bind:value={newTodo}
                            placeholder="Add a new todo"
                            on:keydown={e => e.key === 'Enter' && addTodo()}
                        />
                        <button on:click={addTodo}>Add</button>
                    </div>
    
                    <ul class="todo-list">
                        {#each todos as todo (todo.id)}
                            <li class:completed={todo.completed}>
                                <input
                                    type="checkbox"
                                    checked={todo.completed}
                                    on:change={() => toggleTodo(todo.id)}
                                />
                                <span>{todo.text}</span>
                                <button on:click={() => deleteTodo(todo.id)}>Delete</button>
                            </li>
                        {/each}
                    </ul>
                </main>
    
                <style>
                    .container {
                        max-width: 600px;
                        margin: 0 auto;
                        padding: 20px;
                        font-family: Arial, sans-serif;
                    }
    
                    .input-group {
                        display: flex;
                        gap: 10px;
                        margin-bottom: 20px;
                    }
    
                    input[type="text"] {
                        flex: 1;
                        padding: 8px;
                        border: 1px solid #ddd;
                        border-radius: 4px;
                    }
    
                    .todo-list {
                        list-style: none;
                        padding: 0;
                    }
    
                    li {
                        display: flex;
                        align-items: center;
                        gap: 10px;
                        padding: 10px;
                        border-bottom: 1px solid #eee;
                    }
    
                    .completed span {
                        text-decoration: line-through;
                        color: #888;
                    }
    
                    button {
                        padding: 8px 16px;
                        background: #4CAF50;
                        color: white;
                        border: none;
                        border-radius: 4px;
                        cursor: pointer;
                    }
    
                    button:hover {
                        background: #45a049;
                    }
                </style>
            `).code))({
                target: document.getElementById('app')
            });
        </script>
    </body>
    </html>
    

    To use this:

    1. Save the code as index.html
    2. Open it in a web browser

    Features:

    • Add new todos by typing and pressing Enter or clicking Add
    • Check/uncheck todos to mark them complete
    • Delete todos with the Delete button
    • Clean, modern styling

    Note: You'll need an internet connection since it loads Svelte from a CDN. Let me know if you'd like to add any features like:

    • Local storage to persist todos
    • Filtering (all/active/completed)
    • Due dates
    • Categories

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.