Put in order · Vibe coding with Claude Code course · Module 4: Instagram clone

Sorting: Toggling a Like in map

Arrange the lines of the function that toggles the like of one photo (top to bottom):

Items to put in order

  • : photo));
  • prev.map((photo) =>
  • photo.id === id
  • ? { ...photo, likedByMe: !photo.likedByMe, likes: photo.likedByMe ? photo.likes - 1 : photo.likes + 1 }
  • setItems((prev) =>

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