• This input is wrong: [12, 10, 8, 12, 7, 6, 4, 10, 12, 10, 10] , it is like this: [12, 10, 8, 12, 7, 6, 4, 10, 12, 10] and it test if there are two numbers that are equally frequent, you return the highest. You can print the input with console.log() and it'll appear above the test result.

    Read this: https://docs.codewars.com/training/troubleshooting

  • Hi, thank you for your reply, and yes I am receiving "expected 10 to deeply equal 12" all the time......
    How I can see the Attempt test file?

  • And are you sure those are the tests your code doesn't pass when clicking Attempt?

  • Hey guys, I've made my own test with this:
    describe("Tests", () => {
    it("test", () => {
    var arr = [12, 10, 8, 12, 7, 6, 4, 10, 12];
    Test.assertSimilar( highestRank(arr), 12);
    it("test", () => {
    var arr = [12, 10, 8, 12, 7, 6, 4, 10, 12, 10, 10];
    Test.assertSimilar( highestRank(arr), 10);

    and my code passed both tests, but I still can not pass the Attempt test, any idea why??

  • This comment is hidden because it contains spoiler information about the solution

  • Your problem is in line 3 of your code:

    Note: no empty arrays will be given.

    But you're generating an empty array.

    And then there is another problem:

    If there is a tie for most frequent number, return the largest number among them.

    Your code returns the first value, not the largest one.

  • This comment is hidden because it contains spoiler information about the solution

    • assert.deepEqual should be used

    • Node 12. should be enabled

  • Ruby 3.0 should be enabled, see this to learn how to do it

    Please organize the structure of test fixture as following (although it has been mentioned in the attached link, I'm repeated here again)

    describe "<This message should describe the categories of test groups inside this block>" do
      it "<A short message describing this test group>" do
        expect(...).to eq(...) #Assertions
        #Or Test.assert_equals(user_response, reference_response)
  • func HighestRank(nums []int) int {
    cache := make(map[int]int)
    result, count := 0, 0
    for _, key := range nums {
    value, ok := cache[key]
    if ok {
    value = value + 1
    } else {
    value = 1
    cache[key] = value

    	if value > count {
    		count = value
    		result = key
    return result


  • The description should state that numbers in the array will always be integers.

  • A descending sorted dict takes care of all the test cases.

  • It's slightly worse even. Integer properties come first, sorted as numbers, then other properties, in insertion order. Integers have to be non-negative (!) and no leading or trailing anything. Because property names also are, of course, strings.

    So JS won't sort an array of numbers as numbers, but it will sort an array of strings as numbers, if it is Object.keys.

    It would seem better to just never ever ever rely on property name ordering. If it matters, sort it yourself explicitly, so future generations can see what ordering is actually in use.

  • I had the same question! I digged in and were able to find a very interesting behavior of an object numeric property - If we loop over an object that has integer properties, the properties are sorted (ascending). However, if the key are non-integers, then they are listed in the creation order. In this case, the last should be the largest integer that we want to return if there is a tie!

    You can read more from this article https://javascript.info/object#ordered-like-an-object

  • Loading more items...