Likes vs. Dislikes

Published by Werdna in

YouTube currently displays a like and a dislike button, allowing you to express your opinions about particular content. It's set up in such a way that you cannot like and dislike a video at the same time.

There are two other interesting rules to be noted about the interface:

  1. Pressing a button, which is already active, will undo your press.
  2. If you press the like button after pressing the dislike button, the like button overwrites the previous "dislike" state. The same is true for the other way round.

Create a function that takes an array of button inputs and returns the final state.

Examples

like_or_dislike(["Dislike"]) ➞ "Dislike"

like_or_dislike(["Like", "Like"]) ➞ "Nothing"

like_or_dislike(["Dislike", "Like"]) ➞ "Like"

like_or_dislike(["Like", "Dislike", "Dislike"]) ➞ "Nothing"

Notes

  • If no button is currently active, return "Nothing".
  • If the array is empty, return "Nothing".
Watch a quick demo on how Edabit works.