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.
Hm - specifically, that global variable would give me a different outcome between jsfiddle and codewars?
if you don't mind, could you explain how that would be the case?
Actually - nevermind - I have a feeling I am not able to explain exactly what I am noticing - and this isn't going to be helpful in the end. I really appreciate the input and help. Thank you.
Thank you so much - always helpful. I guess, though -- if you don't mind -- what I was wondering about is that I got such different outcomes from jsfiddle vs codewars.
I was surprised by that and wondered why.
This comment is hidden because it contains spoiler information about the solution
I am certain my code is too complicated, so forgive me. I only started this journey a few weeks ago. I am learning.
Would it be okay to ask for suggestions on debugging? I have thought of every single edge case I can -- and I still average around 20 failed tests each time.
Again, I get one thing I am doing rather clunkily at this point is creating bloated code. For me, in these early stages of learning, separating out each step like this is the best I can do and actually helps me think through the problem...
So, that said -- I apologize for that.
The question I have is this:
Here is my code so far:
(I recently added in some if clauses to try to test to see if those elements were an issue...so that is why they are there...)
function tripledouble(num1, num2) {
var re = /^\d*(\d)\1{2}\d*$/g;
var myArray = num1.toString().split(re);
if (myArray === null) {
return 0;
} else {
var myStr = myArray.toString();
var res = myStr.replace(/[, ]+/g, " ").trim();
var res2 = res + res;
var re2 = new RegExp(res2, "gi");
var MyArray2 = num2.toString().match(re2);
if (MyArray2 === undefined) {
return 0;
}
if (MyArray2 === null) {
return 0;
}
if (MyArray2.length >= 0) {
return 1;
}
else {
return 0;
}
}
}
var num1 = 799900990;
var num2 = 990010000;
alert(tripledouble(num1, num2));
Oh I always do that. Thank you again. I only started learning a few weeks ago.
This comment is hidden because it contains spoiler information about the solution
I don't want to read a response with a spoiler...but thank you.
I re-read the mdn page about reduce...
I then used the sort and reduce method to get rid of duplicates and got rid of the if statement...
I still have the same error.
Only for the smallest test case.
I very much understand that as I practice my code will hopefully get more elegant and less complicated. At this point I am very much simply enjoying the practice.
Thank you very much. Any insight is greatly appreciated.
Don't focus on the promise, please.
What I am curious about is how to resolve the one test that I am not passing.
Is using some sort of exception handling appropriate?
I get that using a promise is too much here.
Thank you.
This comment is hidden because it contains spoiler information about the solution
Hi - I just attempted in js...this is only my second kata so I apologize if I am asking something obvious...
I passed sample tests...so submitted my solution.
I passed all but one test -- and I am a bit confused by the result and what I am supposed to do. I don't want to include any spoilers here...so basically, my question is simply...if I passed the sample tests...how/why would I get a failed test upon an attempt?
And for range.length?
I am happy to provide more info as necessary.