-
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"); }); });
Output:
-
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");
- });
- });
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}