Device name system hackerrank solution javascript