Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
this is cringe dude
cringe
else? tabs?
or it's meme..? then lol
si hacia falta el ultimo condicional?
else if(num === 0)
matematicamente no hace falta un -0This comment is hidden because it contains spoiler information about the solution
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 areturn num
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
tothis
because prototypes work as a function of the string class. Your code is failing becausex
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.Loading more items...