Ad
  • Custom User Avatar

    Thanks Balkoth, my mistake!

  • Custom User Avatar

    The testing framework seems to be buggy - go to Kata http://www.codewars.com/kata/5356ad2cbb858025d800111d/train/javascript

    With my solution, I get the following error:

    Expected: ["Bob"], instead got: ["Bob"]

    ...obviously, these are the same, so it should have passed! Below is my solution and test data (spoiler alert):

    Solution:

    function capMe(names) {
    var capitalised = [], newName;
    for (var i = 0; i<names.length; i++) {
    newName = names[i].toLowerCase();
    newName = newName.charAt(0).toUpperCase() + newName.slice(1);
    capitalised.push(newName);
    }
    return capitalised;
    }

    TEST CASES:

    var test = ['bob'];
    Test.assertEquals(capMe(test), ['Bob']);
    test = ['bob', 'james', 'CHRIS'];
    Test.assertEquals(capMe(test), ['Bob', 'James', 'Chris']);