7 kyu
Capitalize first letter of a string
1,182 of 1,207donaldsebleung
Loading description...
Fundamentals
Object-oriented Programming
Regular Expressions
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Don't waste your time here. Bad kata
Expected: 'History is a very special subject. what do you think?', instead got: 'History is a very special subject. what do you think?'
?
language?
JavaScript. My solution returns 'this' when the first letter is outside the a-z range. When it already starts with a capital, for example. That's probably causing the issue, but I don't know why.
RISC-V: missing fixed edge case test with "Z".
Fixed, thanks
The click here button in the description doesn't work. Seems like Codewars disabled inline JavaScript. You might want to use a CSS hover instead.
Fixed in the RISC-V translation, by removing the offending link altogether.
"".capitaze()
is not tested."capitaze" ?
This comment has been hidden.
How to fix the problem:
Test
implicitly calls several methods, and one of them isString.prototype.toUpperCase
. If you changed the content such that it's returning something else, theTest
fixture itself breaks, and nothing will pass. (And if you throw stuff inside, then you know what happens :P)However, I found that this works:
This will make toUpperCase silently do nothing, and doesn't break
Test
fixture. Probably the best.To everyone else: Before the kata is fixed, you can 'unbreak' the kata by adding the above code along with your submission.
This comment has been hidden.
Could you do the same for Coffeescript? (
String::toUpperCase = -> @
)The 'toUpperCase() has been disabled' error appears also in the CoffeeScript version.
I am NOT using "toUpperCase" or "toLowerCase" in my solution, however, I always get the error:
throw "toUpperCase() has been disabled for the purposes of this exercise";
What's up with this kata???
This comment has been hidden.
This comment has been hidden.
No matter what solution I try I get:
I am not using toUpperCase.
I have the same issue.
Me too :/
This comment has been hidden.
@smolen,
Many thanks for reporting this issue, I have just tried the Kata myself and found it throwing the very same error which is weird because I have not encountered this error before in this Kata and I do not recall editing the Kata in any way ever since it was approved (which it did not have issues back then). I believe that some update on Codewars (perhaps regarding JavaScript language versions) broke this Kata. I will investigate this issue in due time.
Cheers, donaldsebleung
Tricky! I got hung up on that same thing ("History... ") and then realized what I was actually returning ;-)
Very nice kata, I solve the main algoritham in few minutes, and then got caught up in type conversion, obvouslly I need to read little bit more about this when writing prototype methods.
This comment has been hidden.
CoffeeScript translation kumited! please accept :D
Translation approved :)
This comment has been hidden.
I think the problem is that when checking for equality (in the test cases) there is a difference between a literal character (e.g.
"H"
) and its HTML special characters version (e.g."H"
) despite both of them displayed the same way to the user. Maybe try implementing an algorithm that converts lowercase letters to literal uppercase letters (e.g."h" => "H"
, not"h" => "H"
)?My test also fails but seems to return identical results. Expected: Hello world, instead got: Hello world
I posted my code last week, and marked it as a spoiler. So, let me know and I will post it and mark it as a spoiler again.
Hi, thank you for the bug report; however, I can't seem to find the code that you posted in the comments. May you please post it again?
Thank you very much.
Cheers, donaldsebleung
you are not returning a string ;)
Hi, i didn't understand why last test failed.
I have the same error as the user
test case failed saying:
Expected: History is a very special subject. what do you think?, instead got: "History is a very special subject. what do you think?"
I do not use and
Thanx!
Hello, I'm not very sure why either because I have not encountered the same problem.
May you please post your code here (and mark it a spoiler)? I will take a look at it.
Cheers, donaldsebleung
This comment has been hidden.
I got around this same error by using this.split('').join('') to get the string. I had the same problem before doing so, all passed except the last.
i got this same error too with code
return this;
. butreturn this.toString();
passed the testsThis comment has been hidden.
Don't forget to prevent
.toLocaleUpperCase()
and.toLocaleLowercase()
.Thanks for the suggestion, I will disable them right now :D
Edits complete, potential cheats disabled. Issue resolved.
One of my Advance test case failed saying: Expected: History is a very special subject. what do you think?, instead got: "History is a very special subject. what do you think?"
The expected and actual result looks same to me. What is the input string exactly?
That is a bit weird indeed. The input string was exactly that:
"History is a very special subject. what do you think?"
That advanced test case was testing if the string will be un-capitalised if the input string is already capitalised.Allow me to investigate this bug and hopefully I will be able to reply to you within a few days.
Thank you for the error report.
only way for me to pass it was to return this.split('').join(''); on the sentense that was already capitalized.
Apparently, 'this' is an object instead of a string, even though my solution still passed the test in most cases. Use this.split('').join('') to get the string and work with that.
Thanks to both of you.. return this.split('').join(''); worked well for this kata... but return this; was working fine in Visual Studio, so I thought it must work here as well :)
You can get a real string (or number) from an object by
.valueOf()
.Approved! :)
Thanks a lot :D
I was sure this kata has been done before?
Oh, didn't realize the constraints beforehand. Ignore this :)