Ad
  • Default User Avatar

    I think it's more like 6kyu

  • Default User Avatar

    (JS) Push and unshift methods do not work when toLowerCase used in any part of code. In browser console code work fine

  • Custom User Avatar

    random tip, I tend to read these like a sentence.. so 0 <= x <= 4 would read as: 0 is "less than or equal to" x and x is "less than or equal to" 4.

  • Custom User Avatar

    Wouldn't that render this kata trivial and not deserving a 5kyu rating?

  • Custom User Avatar

    the values for the x should be between those parameters

  • 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.

  • 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?

  • Default User Avatar

    Wow, new method, thanks!

  • Custom User Avatar

    You have to use the filter-method

    Did you read the description? "have to" means it is required.

    The title also says Filter in it and there is a link to MDN docs.

  • Default User Avatar

    Author have to specify that you required to solve this cata with filter method, not mention it. He have to point out that other solve variations wouldn't pass tests.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    If you try to solve it with reg exp, you have to keep in mind .match method return either non empty array of matches or null. So you need to not just match (think for other methods for null check)

  • Loading more items...