Ad
  • Custom User Avatar

    funny kata, since when was "y" a vowel :(

    literally right there in the first word of your comment

  • Custom User Avatar

    Keep practicing, you can do it.

  • Custom User Avatar

    From the first paragraph of the Wikipedia article about Y (emphasis mine):

    Y, or y, is the twenty-fifth and penultimate letter of the Latin alphabet, used in the modern English alphabet, the alphabets of other western European languages and others worldwide. According to some authorities, it is the sixth (or seventh if including W) vowel letter of the English alphabet. In the English writing system, it mostly represents a vowel and seldom a consonant, and in other orthographies it may represent a vowel or a consonant. Its name in English is wye (pronounced /ˈwaɪ/), plural wyes.

  • Custom User Avatar

    Ditto, which is odd because I changed the test data to (1,1000000) and it passes. I assume that would be the largest range. Is there something I'm missing?

  • Custom User Avatar

    The kata is great.
    Hint: Look at the series carefuly (Especially look at divisors, how it changes)

  • Custom User Avatar

    Read other solutions, see how could you make it shorter. And the number of lines doesn't necessarily reflect the kata's difficulty.

  • Custom User Avatar

    For this specific instance, its completely arbitrary. Doesn't make one difference.

    There is a difference if you are wondering though. In the solution, he uses a pre-increment rather than a post increment like in your question. It increments the number before the statement executes. It doesn't make a difference because the only thing in that statement is '++i'. Here's an example of it:

    let num1 = 0;
    console.log(num1++) // Outputs 0. The line executes then num1 increments after. This is called a 'post-increment'
    console.log(num1) // Outputs 1.
    
    let num2 = 0;
    console.log(++num2) // Outputs 1. It increments BEFORE the line executes. This is called a 'pre-increment'
    console.log(num2) // Outputs 1. 
    
    

    FUN FACT: There is another difference but I'm not sure it applies to Javascript, but in C++ my professor once told me that, in a for-loop, pre-increments are much more efficient, and that big data companies always use pre-increments when applicable because of that. Could be the reason why its used here, I know I use it because of that fact lol.