Challenge Search and Replace has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
Would you please add the following test case?
myReplace("His name is KING", "KING", "Tom") should return "His name is TOM"
My code:
function myReplace(str, before, after) {
var wordArray = str.split(' ');
for (var i = 0; i < wordArray.length; i++) {
if (wordArray[i] === before) {
// get case list
// ArraY shoud be [true, false, false, false, true]
var caseList = [];
for (var j = 0; j < wordArray[i].length; j++) {
if (wordArray[i].charAt(j) == wordArray[i].charAt(j).toUpperCase()) {
caseList.push(true);
} else {
caseList.push(false);
}
}
// console.log(caseList + before.length);
var afterWithCase = "";
for (var k = 0; k < after.length; k ++) {
if (k >= caseList.length) {
afterWithCase = afterWithCase + after.charAt(k);
continue;
}
if (caseList[k]) {
afterWithCase = afterWithCase + after.charAt(k).toUpperCase();
// console.log("false;" + after.charAt(k).toUpperCase());
} else {
afterWithCase = afterWithCase + after.charAt(k).toLowerCase();
// console.log("false;" + after.charAt(k).toLowerCase());
}
}
wordArray[i] = afterWithCase;
}
}
return wordArray.join(" ");
}
myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
@peterdeng can you give your reasoning for adding this test case? Are the instructions unclear? Do you want to make the challenge more difficult? I think the challenge is sufficient the way it is but I'm up for discussing it.
@erictleung Thanks for your reply.
NOTE: Preserve the case of the original word when you are replacing it.
Maybe we do not need to increase the difficulty for this challenge.
But in a case like this, would you please modify this description instead?
before:
NOTE: Preserve the case of the original word when you are replacing it.
after:
NOTE: Preserve the case of the first char in the original word when you are replacing it.
or just explain that only the first char in the word may be uppercase.
Sorry for my misunderstanding of the phrase "the case of the word",
Did I took it too complicated?
Hi @peterdeng! Thank you for reporting this issue.
I see what you mean here. "Case" means the distinction between UPPER and lower case. The word does not mean just the first letter, that's "capitalization."
Going from the tests and the note, I believe this challenge means capitalization rather than case. The description should be updated to clarify this.
While we're at it, the formatting of this note is out of the ordinary. We talked a bit about note formatting in https://github.com/FreeCodeCamp/FreeCodeCamp/pull/11867 This note should probably be updated to the format used there.
Hi @systimotic , Thank you for you reply.
Going from the tests and the note, I believe this challenge means capitalization rather than case. The description should be updated to clarify this.
me too. OK for me, please close this issue after the modification. or if I need to close this issue by myself, please contact with me.
Hi, If we need to fix the language in the challenge, I can do that. Can anyone confirm if this issue needs help?
@dhcodes / @raisedadead (I tag you both coz I don't know other moderators who can help/respond)
@ajain17 Well most of us do... 😉 ! or we will make sure someone does repond. Hit us up in the chat for anything (that needs a chat/discussion). Most mods follow that.
And yup please go ahead with the PR when you are ready! Make sure you address @systimotic 's https://github.com/FreeCodeCamp/FreeCodeCamp/issues/11862#issuecomment-264212993 above.
Thanks. I'll work on it today.
@ajain17, Are you still working on this? If not, I would like to work on this issue.
@brianhankins please go ahead and make pull request if you are ready. Thanks.
@raisedadead @brianhankins I have a pull request ready for this issue if needed :question:
@codeman869 yeah sure why not go ahead.
Thank you for fixed this for all the freeCodeCampers.
BR
Peter Deng
2017-01-07 1:02 GMT+09:00 mrugesh mohapatra notifications@github.com:
Closed #11862 https://github.com/FreeCodeCamp/FreeCodeCamp/issues/11862
via #12397 https://github.com/FreeCodeCamp/FreeCodeCamp/pull/12397.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/FreeCodeCamp/FreeCodeCamp/issues/11862#event-914209097,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABTZ1PIm4Hvr-XWfckEHfhHYikT_Xjwuks5rPmWygaJpZM4K_LVT
.
Most helpful comment
@ajain17 Well most of us do... 😉 ! or we will make sure someone does repond. Hit us up in the chat for anything (that needs a chat/discussion). Most mods follow that.
And yup please go ahead with the PR when you are ready! Make sure you address @systimotic 's https://github.com/FreeCodeCamp/FreeCodeCamp/issues/11862#issuecomment-264212993 above.