Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • 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.

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

  • Oh haha thanks! Got it.

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

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

  • Sorry I'm not sure I understand what you mean. I thought x was the parameter? I am looking up how to add properties and methods to String.prototype and everything I search looks similar to my code. I tried adding "this.x = x" and "this.digit = x" at the beginning because I thought that was what you were getting at but it didn't change my results.

  • Hey guys my name is Lexi and I am a first year student at UCT. I have been given a project in java and I don't really know how to do it. If there is anyone who is understands java and is willing to help please email me at lexiwellsqw@gmail.com . I will really appreciate it if someone could try to help it would contribute tremendously to my career as a programmer.

  • 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.

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

  • 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.

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

  • Please can you post Kata-specific problems on the discourse page for that Kata instead of the forum which is for general topics. Each Kata has an automatic discourse page in which you can mark your comment as a question, which means it's easier for me to help (since it's easier to find). Also, since this is a forum page, I can't mark your comment as a spoiler, meaning people can look at your code and use it themselves, however on the discourse page I can hide your solution.

    Somebody already answered your question on your other comment so I won't comment about that here.

  • Hi all, I am new to javascript and am having trouble with the Split Camelcase kata.

    Description:

    Split a camelcase string into individual words, the return value must be a single string of words seporated by one whitespace.

    The strings are to be split on the capital letters like so:

    'StringStringString' => 'String String String'

    **I completed this with no problem, but what it doesn't mention in the instructions is that if two or more capital letters are next to each other, you only add a space before the first capital letter. So "TTThisIsAnExample" would become "TTThis Is An Example" and not "T T This Is An Example" ... if that makes sense. So this is the suuper inefficient code I wrote to try to satisfy those tests, but apparently it is an infinite loop and I have no idea why:

    function splitter(str){
    let array = str.split('');
    for (let i=0; i<array.length; i++) {
    if(array[i] === array[i].toLowerCase() && array[i + 1] === array[i + 1].toUpperCase()) {
    array.splice(array.indexOf(array[i + 1]), 0, " ");
    } else if(array[i] === array[i].toUpperCase() || array[i] === " ") {
    continue;
    }
    }
    return array;
    }

    I would appreciate any help people could offer on this code. Thanks!

  • I never clicked on "train" so it was never added to my unfinished kata. Thanks though!

  • @ginnk,

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

  • Loading more items...