Altar.io interview question

Javascript leetcode problem with random values