centuryFromYear [Code]

I'm hungry for coding!  So I joined a site called CodeFights.  It's a really neat place to put one's coding skills to the test and to just get dirty.  It is a perfect place in which to experiment, research, and learn new things.  As a beginner, I am gaining problem-solving skills as well as familiarizing myself with JavaScript.  The CodeFights (here forward referred to as CF) allows the user to choose a language of choice with which to complete the coding challenges or the coding interviews.  Yes!  CF has an option to practice for coding interviews! 

Anyway, here is my code for the Arcade challenge called centuryFromYear. Let me know how I could have coded better. 

Questions:

  1. Is there a simpler way to code the function?
  2. Do you see a possible test case that would fail?
  3. Is my code readable or unnecessarily complex?
  4. How did I do with following coding conventions (variable names, indentation, brackets, parentheses, etc)?

centuryFromYear

Description:  Given a year, return the century it is in.  The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc. (In other words, I am to create a function that will achieve this.)

Language:  JavaScript

My code (51 lines; not including the test code far below):

(The following was accepted by CF as a working solution. It passed all 9 test cases far below.)

function centuryFromYear(year) {
var yearToString = year.toString();
var century = 0;
var strCentury = 0;

//Checks for four-digit year.
if (yearToString.length === 4) {
    //Checks for final year of the century to prevent adding
    //a century.
    if (yearToString.substring(1) === "000") {
        century = yearToString.substring(0,2);
        century = parseInt(century);
    }
    else if (yearToString.substring(2) === "00") {
        century = yearToString.substring(0,2);
        century = parseInt(century);
    }
    //Otherwise adds century and parses the string to initialize
    // the variable century with the proper number of centuries.
    else {
        century = Number(yearToString) + 100;
        strCentury = century.toString();
        strCentury = strCentury.substring(0,2);
        century = parseInt(strCentury);
    }
}

//Checks for a three-digit year.
else if (yearToString.length === 3) {
    //Checks for final year of the century to prevent adding
    //a century.
    if (yearToString.substring(1) === "00") {
        century = yearToString.substring(0,1);
        century = parseInt(century);
    }
    //Otherwise adds century and parses the string to initialize
    // the variable century with the proper number of centuries.
    else {
        century = Number(yearToString) + 100;
        strCentury = century.toString();
        strCentury = strCentury.substring(0,1);
        century = parseInt(strCentury);
    }
}

//Checks for two-digit year.
else if (yearToString.length === 2 || 1) {
    century = 1;
}
return century;

}

Tests (custom test code I wrote):

//Runs through nine test cases to ensure the function returns the proper //century for any given year. var testArray = [1905, 1700, 1988, 2000, 2001, 200, 374, 45, 8];

//Iterative loop for testArray. for (var i = 0; i < testArray.length; i++) { document.write("Test Case " + (i + 1) + ": " + centuryFromYear(testArray[i]) + " century" + "<br>");
}

Output:

Test Case 1: 20 century
Test Case 2: 17 century
Test Case 3: 20 century
Test Case 4: 20 century
Test Case 5: 21 century
Test Case 6: 2 century
Test Case 7: 4 century
Test Case 8: 1 century
Test Case 9: 1 century