Ad
  • Custom User Avatar

    Think I have some adviсes for your code. Firstly you receive an infinite loop because when the space are added to position whith index i+1 (btw you don't need use construction "array.indexOf(array[i + 1])", just "i+1") in the next round of your loop you will examine element of array which contents this just added space. Space satisfies condition of your if, your script will add enother space to next position and examine it in the next round. You will never come to else branch.
    You must move on to position after just added space in next round. Add "i=i+2;" after "array.splice...;" (+2 because you don't need to examine space and next standing uppercase letter). And remove your else branch. Another thing: in condition of your loop you must handle elements only up to "i < array.length-1". The last element will be examinated in the penultimate round.

  • Custom User Avatar

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

  • Custom User Avatar

    Change x to this because prototypes work as a function of the string class. Your code is failing because x is "undefined" because it doesn't require a parameter - it instead calls the "digit" function that a string now has (look up prototypes, and look at the testcases to see what I'm talking about). You can see this if you console.log(x) and console.log(this) just before your if statement.

  • Custom User Avatar

    Put console.log(this) in your code so you can see the input parameter. Your code is failing because it returns false if it is type string...but all the parameters should be a string to be a digit.

  • Custom User Avatar

    @ginnk,

    Have you tried looking at your profile page and clicking on the Kata tab? There are options for Completed and Unfinished katas.