Likes vs. Dislikes

Published by Deep Xavier 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 and vice versa.

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

Examples

likeOrDislike(["Dislike"]) ➞ "Dislike"

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

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

likeOrDislike(["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.