Move History

Rooted by: hello world
Fork Selected
  • Description

    Let's add a bit of some i18n

    Code
    const helloLangs = {
      english: "hello",
      pirate: "yar"
    }
    
    const hello = (whoever, lang="english") => `${helloLangs[lang]} ${whoever}`;
    Test Cases
    describe("Solution", function(){
      it("defaults to english", function(){
        Test.assertEquals(hello('gotham'), "hello gotham");
      });
      
      it("responds in pirate when passed 'pirate' as the language", function(){
        Test.assertEquals(hello('gotham', 'pirate'), "yar gotham");
      });
    });
  • Code
    • const hello = whoever => `hello ${whoever}`;
    • const helloLangs = {
    • english: "hello",
    • pirate: "yar"
    • }
    • const hello = (whoever, lang="english") => `${helloLangs[lang]} ${whoever}`;
    Test Cases
    • describe("Solution", function(){
    • it("should test for something", function(){
    • it("defaults to english", function(){
    • Test.assertEquals(hello('gotham'), "hello gotham");
    • });
    • it("responds in pirate when passed 'pirate' as the language", function(){
    • Test.assertEquals(hello('gotham', 'pirate'), "yar gotham");
    • });
    • });