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.
Very good. But this issue is solved. Read my answer above and correct you soluton to pass the tests.
I have this problem either
This comment is hidden because it contains spoiler information about the solution
Thanks a heap for the response. I truely appreciate it and yes I should have clarified overall debugging and style tips was what I was after.
I'm not sure if you just want to have this code debugged, or if you are asking for some style tips too.
Anyway here's some advice to point you in a better direction:
Don't worry about "efficiency". Focus firstly on readibility and functionality.
You seem to be going to a lot of effort to get to that single
return b
at the bottom of the method. Single return points are nice but should not be at the expense of simplicity or readibilty. So you can simplify some of thatb
logic into oblivion.I don't recommend "magic" numbers in code. The next person to read this won't necessarily know what you meant. e.g. Instead of 65 and 90 why not use 'A' and 'Z'?
You need to consider what are all possible inputs. The Kata description implies the string could be
null
so you need to cope with that instead of doingtoUpperCase
without 1st checking for null. In fact, THIS IS YOUR BUG. If you deal properly with the null input then your code passes OK.If in doubt what is going on you then you ought to scatter some debugging output around in your code - eg if you did
System.out.println
to show what the input stringss1
ands2
were then you would have found the problem.When something gives a stacktrace read it! NPE on your line 6. Can't be any clearer than that :-)
b
why not call itretValue
- then the meaning is clear and the comment is not needed anymore. Also comments that just say exactly what the code is doing serve no purpose:else if(sum1==sum2) b = true; // else compare sums.
Hope some of that helps
Cheers,
DM
This is no issue! Read the description!
"If the string contains other characters than letters, treat the whole string as it would be empty."
Please help me! Here is a JavaScript error message!
✘ '!!' vs '7476' - Expected: true, instead got: false
✘ '##' vs '1176' - Expected: true, instead got: false
Help me where the code is wrong!
THX.
hi,wickedswami215!What is the error of the output?If you get the array length error?Please make an array of empty judgement and need a return value,for example:return [];If it is the other error,please list the error message.
hi,abreud!Do you have an empty array of judgment ?
I have this same error :(
This comment is hidden because it contains spoiler information about the solution
no tests for the special cases described in the definition allow a lot of technically wrong solutions (usually soltions that return [0,0] instead of [] when input is empty or nil/null)
Hi
Annietuyan
,the kata description says:
If the input array is empty or null, return an empty array
. So according to the error message, you do not check, if the input is null OR you try to get the propertylength
of the input befor the check for null.This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution