gpt-4.1-mini-2025-04-14· OpenAI
WildChat-4.8M (AI2)
Hi
- User
Hi
- Assistant
Hello! How can I assist you today?
- User
Hwi
- Assistant
Hi there! How can I help you today?
- User
generate code for todoapp
- Assistant
Sure! Here's a simple Todo List App using React. This example includes adding, toggling (complete/incomplete), and deleting todo items.
import React, { useState } from 'react'; function TodoApp() { const [todos, setTodos] = useState([]); const [input, setInput] = useState(''); const addTodo = () => { if (input.trim() === '') return; setTodos([...todos, { id: Date.now(), text: input.trim(), completed: false }]); setInput(''); }; const toggleTodo = (id) => { setTodos( todos.map(todo => todo.id === id ? { ...todo, completed: !todo.completed } : todo ) ); }; const deleteTodo = (id) => { setTodos(todos.filter(todo => todo.id !== id)); }; return ( <div style={{ maxWidth: 400, margin: '2rem auto', fontFamily: 'Arial, sans-serif' }}> <h2>Todo List</h2> <input type="text" placeholder="Add a todo" value={input} onChange={(e) => setInput(e.target.value)} onKeyDown={(e) => e.key === 'Enter' && addTodo()} style={{ padding: '0.5rem', width: '70%' }} /> <button onClick={addTodo} style={{ padding: '0.5rem', marginLeft: '0.5rem' }}>Add</button> <ul style={{ listStyle: 'none', padding: 0 }}> {todos.map(todo => ( <li key={todo.id} style={{ margin: '1rem 0', display: 'flex', alignItems: 'center' }}> <input type="checkbox" checked={todo.completed} onChange={() => toggleTodo(todo.id)} style={{ marginRight: '0.5rem' }} /> <span style={{ flexGrow: 1, textDecoration: todo.completed ? 'line-through' : 'none' }}> {todo.text} </span> <button onClick={() => deleteTodo(todo.id)} style={{ marginLeft: '0.5rem' }}> Delete </button> </li> ))} </ul> </div> ); } export default TodoApp;How to use:
- Create a React project (using Create React App or another setup).
- Save this code as
TodoApp.jsx. - Import and use
<TodoApp />in your main component.
If you want code in a different language/framework or with more features, just let me know!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- gpt-3.5-turbo-0301Compare side by side →
- gpt-4-0314Compare side by side →
- gpt-3.5-turbo-0301Compare side by side →
- gpt-3.5-turbo-0301Compare side by side →
- gpt-4-0314Compare side by side →
- gpt-4-0314Compare side by side →
- gpt-4-0314Compare side by side →
- gpt-3.5-turbo-0301Compare side by side →
- gpt-3.5-turbo-0301Compare side by side →
- gpt-4-0314Compare side by side →
- gpt-4-0314Compare side by side →
- gpt-4-0314Compare side by side →