Ad
  • Custom User Avatar

    What I am realizing is that I need to figure out why this prop comes back as "undefined" when I try to access them. Because of that I am unable to determine the index location of the duplicates.

  • Custom User Avatar

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

  • Custom User Avatar

    Thanks Johan, I thought they were all the same because this is the input array I am receiving. This is my first time working with symbols in this way. I'm curious why they are represented in this manner rather than the actual symbols.

    Input Array:

    [
    Symbol(), Symbol(), Symbol(),
    Symbol(), Symbol(), Symbol(),
    Symbol(), Symbol(), Symbol(),
    Symbol(), Symbol(), Symbol(),
    Symbol(), Symbol(), Symbol(),
    Symbol(), Symbol(), Symbol(),
    Symbol(), Symbol(), Symbol(),
    Symbol(), Symbol(), Symbol(),
    Symbol(), Symbol(), Symbol(),
    Symbol()
    ]

    How do I acess the actual content of the symbol in order to differentiate them?

    Since I'm using a hash map to determine duplicates, I will end up having a symbol within a symbol?

    _ _

    I am console logging the following to understand what is going on:

    Type of elements in input array: symbol

    My HashMap: I do see that it records a second entry for one of the symbols. Though I can't differentiate it myself visually.

    valueMap {
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 2,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1,
    [Symbol()]: 1
    }

    I iterate over the hash map to find and return the prop that contains 2 and set that prop equal to a variable, and the console log it, this is where my logic seems to be breaking at the moment.

    Duplicate is undefined (meant to be return value) as a undefined (meant to be data type of the value)

  • Custom User Avatar

    JS Version -
    The spec says there should only be 1 duplicate in each input.

    During the random tests I receive an input array containing a list of 28 duplicate symbols "symbol()". Weirdly, it's my current understanding that the point of a symbol is that it should be unique.

    Can anyone point me in the direction of what I am not understanding or how to approach this? Thank you!

  • Custom User Avatar

    Well, I figured out what was wrong. Turns out there's a differeance between .substring() and .substr() in JS. Check it out if you're troubleshooting and are unaware of the differeance.

  • Custom User Avatar

    Wow, your solution made me realize there is a differeance between .substring() and .substr().

  • Custom User Avatar

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

  • Custom User Avatar

    I had no idea you can import libraries into CodeWars. Thanks for showing me that.

  • Custom User Avatar

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

  • Custom User Avatar

    I ran into this as well. Your numbers are returning as strings in your return array instead of as numbers. You need to find a way to convert those strings into numbers into a new array, and then return that resulting array. ['2', '4', '0'] => [2,4,0]

  • Custom User Avatar

    Wow, really had to dissect this solution to understand how it was getting to the solution. How in the world do you think this way. Genius!

  • Custom User Avatar

    Found a typo in the instructions. "You have a* function with one side of the DNA..."

  • Custom User Avatar
  • Custom User Avatar

    Ah, makes sense. Thank you.

  • Custom User Avatar

    I am wondering why the variable "s" above is delcared using "var" as opposed to "let" seeing as though it's value will change throughout the lifecycle of the function. Can anyone please explain?