Ad
  • Custom User Avatar
  • Custom User Avatar

    cringe

    else? tabs?

    or it's meme..? then lol

  • Custom User Avatar

    si hacia falta el ultimo condicional?
    else if(num === 0) matematicamente no hace falta un -0

  • Custom User Avatar

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

  • Custom User Avatar

    cool, you thought of all kinds of returns, but then you overload your function when it could only do one thing, the only thing it needs to do is turn positive into negative, positive is all those above 0, so num > 0 return "some way to pass it negative", the rest can be returned the number itself, so just put a return num

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

  • Default User Avatar

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

  • Default User Avatar

    Oh haha thanks! Got it.

  • Custom User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

    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.

  • Default User Avatar

    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.

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

  • Default User Avatar

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

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

  • Loading more items...