Ad
  • Default User Avatar

    same with me ia am using python but it is showing wrong

  • Custom User Avatar

    As of 2024 ~~ 10 years later, your solution passes the kata, closing ! ^^

  • Custom User Avatar

    OP solved it, closing. The original solution posted above has a wrong syntax --> should be +(++x)

  • Custom User Avatar

    As of 2024 ~~ 10 years later, your solution passes the kata, closing ! ^^

  • Custom User Avatar
  • Custom User Avatar

    On social media, OP usually means "original poster" or "original post."

  • Default User Avatar

    please, wha is OP??. i have the same issue

  • Default User Avatar

    Seems too easy for a 5kyu

  • Custom User Avatar

    Description does not ask you to return equal. It specifies to return the modified string except when the final string is longer than 140 chars / empty , or when the original input is already empty.

    Your code, OTOH, returns equal for final strings of length 140, modified string for lengths less than 140 and False for other cases.

  • Custom User Avatar

    I already told you exactly which sample test your code is failing, use Pythontutor or other IDE to debug your code step by step and see what's wrong with it. Don't chain methods until you properly understand what they return in each of them, pull them apart and log what they return, you'll find out what's wrong with your code easier that way.

  • Custom User Avatar

    hi how did you solve this problem

  • Default User Avatar

    Undefined is valid only when it's "" in test - empty string has no length. So I add check on string.length with break to quit code execution: switch (str.length) { case 0: return false break} ABOVE toUpperCase method line, so it had to be irrelevant wether toUpperCase were used in code in lower lines or not.

    Why have testing keep throw an toUpperCase error when I quit code execution before toUpperCase method has been applied?

  • Custom User Avatar

    The tests have no problem with either method, it's your code that's trying to use them wrong, read the error message:

    TypeError: Cannot read properties of undefined (reading 'toUpperCase')
    

    undefined doesn't have toUpperCase method, that's a string method. Debug your code, add some console.log()s to help you with that. Read this: https://docs.codewars.com/training/troubleshooting

    Currently, your code fails this sample test:

    assert.strictEqual(generateHashtag("code" + " ".repeat(140) + "wars"), "#CodeWars")
    
  • Default User Avatar

    I keep rewrite my code over and over again. I do not use touppercase, (though, why?), I keep have right answers in my browser console, and I keep have errors when trying to test it. Different errors. First version apparently didn't like touppercase using, ok, I changed it. Second version didn't like an replace method (not sure but still, it was adviced in discussion), I changed it too. Third version didn't like an one word case test - expected false to equal '#CodeWars'. But I do have '#CodeWars' as a result in browser console! I also do not check string.length too early, and still, errors.

    The test for this cata is written POORLY and BUGGY! Why does it reject touppercase method and keep throw an error? It also reject fromCharCode(charCodeAt) method and also keep throw an error.

    What. Is. Wrong. With. This. Cata???

    If your test code do have problems with certain methods, then may be you'd mention it in cata conditions not to use this and that?

  • Default User Avatar

    Ok, but why? Isn't it an cata testing problem if it keep throw error when you solve a task with method that is different from what author expected you'l be using?

  • Loading more items...