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.
"alr approved some time ago"
Comparison operators such as
<=
and>
coerce their arguments to numbers, if necessary. ( If this is, indeed, JavaScript. )Coercion has some subtleties though, that's very probably what's biting you. If you're new to coding, it is probably better not to rely on coercion; there are other ways with fewer subtleties, that will inflict fewer bugs.
The argument
s
passed in is a string not a number, you need to test whether the string represents a single valid number.This comment is hidden because it contains spoiler information about the solution
CW GitHub Wiki - Kata Best Practices - Follow Established Conventions
[Python] Name of user solution should be
is_digit
notisDigit
(source: PEP8).As a side note, I don't get why the function would even be named "is digit" in the first place? We're testing whether the given string represents a valid number (which more often than not contains multiple digits along with an optional decimal point and/or a negative sign), not whether it represents a single digit.
Thank you Johan. I was able to get all the tests to pass after your tip. All the best. Chris
Print not just the input, but also the type of the input. If it's a string, also print the length.
This does not really have anything to do with this issue - the input is very probably correct in this specific case ( if it is what I think it is, that is. )
I added a translation for C# if anyone is interested in having a look at it.
I want to follow up with a specific example. I was able to get 410 of 411 tests to pass. I have one test that will not show me an outcome via console.log and still fails. No idea where to go from here. On a level 8. I was able to get one other with no console.log output working.
If anyone wants to point me in the right direction, I would appreciate it.
This comment is hidden because it contains spoiler information about the solution
https://www.w3schools.com/js/js_type_conversion.asp
When JavaScript tries to operate on a "wrong" data type, it will try to convert the value to a "right" type.
Below the code editor there's a
Sample Tests
section. You can see the basic tests there. If you want to find out the inputs of the main tests, you shouldSystem.out.println(argumentVariable)
inside the function to see it.By the way, you solution doesn't work because the input is a string, you can't subtract strings.
Usually you can write to standard output of some kind, the exact way depends on the language. For C# it's
Console.WriteLine
, for Java -System.out.println
,console.log
and similar for JavaScript etc. You can see the program output in the test output window.This comment is hidden because it contains spoiler information about the solution