Create the Todo
class with the following methods:
constructor()
: initialization with the empty list of TODO items;addItem(title, priority)
: adds an item with the given title and priority to the list; the method returns the unique id assigned to the item (positive integer);removeItem(id)
: removes the item with the givenid
from the list of items: it should returntrue
if the item with the givenid
was successfully removed orfalse
if there was no such item;getItem(id)
: returns an object that contains theid
,title
, andpriority
fields for the item with the providedid
(if there is no such item, it should returnnull
);next()
: returns the highest priority item from the list in the same format asgetItem
(if there are several items of the same priority, return the one that was added before others; if there are no items in the list, throw an error).