Step-by-step explanation:
The literary element in the sentence "He was swept away by both fear and joy" is a juxtaposition. Juxtaposition is a literary device that places two contrasting elements, characters, concepts, or ideas side-by-side to emphasize their differences and highlight a deeper meaning. In this case, fear and joy are opposite emotions, and the use of juxtaposition helps to emphasize how the character is experiencing two conflicting emotions at the same time, creating a sense of tension and complexity.