Question · Vibe coding with Claude Code course · Module 3: Twitter clone

Adding to array state

How do you correctly add an item to a state array called items?

Answer options

  • items.push(newItem)
  • items = items + newItem
  • setItems(items.add(newItem))
  • setItems([...items, newItem])

You can check the correct answer by solving this task in the CodeWorlds game.