Move History

Fork Selected
  • Code
    function capitalize(sentence) {
      return sentence.split(' ').map(w => w[0].toUpperCase() + w.slice(1)).join(' ');
    }
    Preloaded Code
    function capitalize(sentence) {
        return;
    }
    console.log(capitalize("i am a javascript programmer"));
    Test Cases
    // Since Node 10, we're using Mocha.
    // You can use `chai` for assertions.
    const chai = require("chai");
    const assert = chai.assert;
    // Uncomment the following line to disable truncating failure messages for deep equals, do:
    // chai.config.truncateThreshold = 0;
    // Since Node 12, we no longer include assertions from our deprecated custom test framework by default.
    // Uncomment the following to use the old assertions:
    // const Test = require("@codewars/test-compat");
    
    describe("Solution", function() {
      it("should test for something", function() {
        // Test.assertEquals(1 + 1, 2);
        // assert.strictEqual(1 + 1, 2);
      });
    });
    
  • Code
    • function capitalize(sentence) {
    • let words = sentence.split(' ');
    • const length = words.length;
    • for (let i = 0; i < length; ++i) {
    • words[i] = words[i][0].toUpperCase() + words[i].substr(1)
    • }
    • return words.join(' ');
    • }
    • console.log(capitalize("i am a javascript programmer"));
    • return sentence.split(' ').map(w => w[0].toUpperCase() + w.slice(1)).join(' ');
    • }